Skip to content

Instantly share code, notes, and snippets.

@Eunsol-Lee
Created March 22, 2017 15:58
Show Gist options
  • Save Eunsol-Lee/3b2c4e0a8bb3b8ef87ebfd3e860bc9fd to your computer and use it in GitHub Desktop.
Save Eunsol-Lee/3b2c4e0a8bb3b8ef87ebfd3e860bc9fd to your computer and use it in GitHub Desktop.
def sumMultiple(n, k):
n -= n % k
return (n + k) * int(n / k) >> 1
def solve(N):
result = sumMultiple(N, 3) + sumMultiple(N, 5) - sumMultiple(N, 15)
return result
T = int(input())
for i in range(T):
N = int(input())
print (solve(N - 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment