Skip to content

Instantly share code, notes, and snippets.

@OussaZaki
Created November 5, 2016 23:20
Show Gist options
  • Save OussaZaki/2a1f4d876226539096c96bcdc7f4d37a to your computer and use it in GitHub Desktop.
Save OussaZaki/2a1f4d876226539096c96bcdc7f4d37a to your computer and use it in GitHub Desktop.
def sum(n, k):
d = n // k
return k * (d * (d+1)) // 2
def euler1(n):
return sum(n, 3) + sum(n, 5) - sum(n, 15)
t = int(input().strip())
for i in range(t):
N = int(input().strip())
print(euler1(N - 1)) # below N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment