From 356218254263f45536bd1b053f8cb9e30450087a Mon Sep 17 00:00:00 2001 From: Bhaavik Pratyush Date: Mon, 16 Apr 2018 19:17:28 +0530 Subject: [PATCH] Update sol2.py --- Project Euler/Problem 01/sol2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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)