Can any one write for me the code to find the sum of consecutive numbers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 5

Can any one write for me the code to find the sum of consecutive numbers

N = int(input()) i = (range(N)) i+=1 while i in range(N): print (int(i))

15th Jun 2021, 10:34 AM
Yiga Mark Dan
Yiga Mark Dan - avatar
3 Answers
+ 3
N = int(input()) a = [i for i in range(0, N + 1)] print(sum(a))
15th Jun 2021, 10:43 AM
SammE
SammE - avatar
15th Jun 2021, 10:45 AM
HNL
HNL - avatar