+ 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
4 Answers
+ 3
Do you think your numbers are exceeding the range of int, (I think it's +-2147483647)?
+ 2
# try this
n = int(input("enter no."))
+ 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?
0
No buti think it's less