diff --git a/Project Euler/Problem 01/sol2.py b/Project Euler/Problem 01/sol2.py index d330387e9..2b7760e0b 100644 --- a/Project Euler/Problem 01/sol2.py +++ b/Project Euler/Problem 01/sol2.py @@ -11,10 +11,10 @@ except NameError: raw_input = input # Python 3 n = int(raw_input().strip()) sum = 0 -terms = (n-1)/3 -sum+= ((terms)*(6+(terms-1)*3))/2 #sum of an A.P. -terms = (n-1)/5 -sum+= ((terms)*(10+(terms-1)*5))/2 -terms = (n-1)/15 -sum-= ((terms)*(30+(terms-1)*15))/2 +terms = (n-1)//3 +sum+= ((terms)*(6+(terms-1)*3))//2 #sum of an A.P. +terms = (n-1)//5 +sum+= ((terms)*(10+(terms-1)*5))//2 +terms = (n-1)//15 +sum-= ((terms)*(30+(terms-1)*15))//2 print(sum)