Project Euler #1: Multiples of 3 and 5

  • + 0 comments

    import math import os import random import re import sys

    def res(x,n): q = (n-1)//x return x*q*(q+1)//2

    if name == 'main': t = int(input().strip())

    for t_itr in range(t):
        n = int(input().strip())
        sol = res(3,n)+res(5,n)-res(15,n)
        print(sol)