+ 2

Python compute

compute sum of all intergers that are multiples of 9 from 1-250

22nd Aug 2018, 7:13 PM
Lawrence Hunter
Lawrence Hunter - avatar
6 Respostas
+ 6
print(3402)
22nd Aug 2018, 8:31 PM
Oma Falk
Oma Falk - avatar
+ 4
# Sum of multiples of k lower from 1 to n print(k*(n//k)*(n//k+1)//2)
22nd Aug 2018, 8:27 PM
VcC
VcC - avatar
+ 3
print(sum([_ for _ in range(1, 251) if _ % 9 == 0]))
22nd Aug 2018, 7:39 PM
Anna
Anna - avatar
22nd Aug 2018, 7:47 PM
Anna
Anna - avatar
+ 3
sum = 0 for i in range(9,251,9): sum += i
22nd Aug 2018, 8:17 PM
Oma Falk
Oma Falk - avatar
+ 1
is 3402 the correct answer?
22nd Aug 2018, 7:42 PM
Lawrence Hunter
Lawrence Hunter - avatar