Created
March 22, 2017 15:58
-
-
Save Eunsol-Lee/3b2c4e0a8bb3b8ef87ebfd3e860bc9fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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