We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Test Cases 2 & 3 give wrong answer not sure what's going on
t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
s = 0
n = n-1
m = n//3
x = n//5
y = n // 15
s += 3*m*(m+1)/2
s += 5*x*(x+1)/2
s -= 15*y*(y+1)/2
print(int(s))
print(int(s))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #1: Multiples of 3 and 5
You are viewing a single comment's thread. Return to all comments →
Test Cases 2 & 3 give wrong answer not sure what's going on
t = int(input().strip()) for a0 in range(t): n = int(input().strip()) s = 0 n = n-1 m = n//3 x = n//5 y = n // 15 s += 3*m*(m+1)/2 s += 5*x*(x+1)/2 s -= 15*y*(y+1)/2 print(int(s))