0

Adding consecutive numbers. Can anyone help with this code .

N = int(input()) #your code goes here i=1 while i<N: i+=1 sum=i+N print(sum)

23rd Dec 2021, 1:16 PM
Debashish Das
Debashish Das - avatar
11 Answers
+ 2
N=int(input ()) sum=0 for i in range(1, N+1) : sum=sum+i print(sum)
23rd Dec 2021, 1:54 PM
Debashish Das
Debashish Das - avatar
0
This worked
23rd Dec 2021, 1:54 PM
Debashish Das
Debashish Das - avatar
0
How is iteration happening in your code.?
23rd Dec 2021, 1:56 PM
Debashish Das
Debashish Das - avatar
0
But there is no iteration happening, the value is going to change once, isnt it?
23rd Dec 2021, 1:59 PM
Debashish Das
Debashish Das - avatar