Monday, June 17, 2013

Saturday, June 1, 2013

14863. Summation of Multiples

http://www.spoj.com/problems/SUM1/


CODE

t=int(input())
for i in range(t):
    n=int(input())
    a=(n-1)/3
    b=(n-1)/5
    c=(n-1)/15
    ans=(3*a*(a+1)/2)+(5*b*(b+1)/2)-(15*c*(c+1)/2)
    print(ans)