+ 1

Need to print the sum of series 3+5+6+10+9+15.....N

My soln int(input("enter no.")) Sum=0 for i in range (1,n): if i%3==0 and i%5==0: Sum+=i Print(sum) But the problem is It is not working for large number like 100000000000

31st Dec 2021, 12:04 AM
Sudalai Vignesh
4 Réponses
+ 3
Do you think your numbers are exceeding the range of int, (I think it's +-2147483647)?
31st Dec 2021, 12:18 AM
HungryTradie
HungryTradie - avatar
+ 2
# try this n = int(input("enter no."))
31st Dec 2021, 12:32 AM
SoloProg
SoloProg - avatar
+ 1
Is your sample 2 different sets of numbers overlapping into one sequence? Numbers +3 is the first set, numbers +5 is the second? Yet your algorithm seems to want numbers that have both "3 and 5" as factors, eg 15, 30, 45. Should you do an if, elif, else statement? Use if to catch multiples of 3 and elif multiples of 5?
31st Dec 2021, 4:41 AM
HungryTradie
HungryTradie - avatar
0
No buti think it's less
31st Dec 2021, 1:07 PM
Sudalai Vignesh