0

Can someone help in the "Sum of Consecutive Numbers" project ?

11th Feb 2021, 6:41 AM
Sarvam Fating
Sarvam Fating - avatar
3 odpowiedzi
+ 3
The answer provided by 12345 is elegant & succinct, but may be a bit advanced for you to understand yet. Might I suggest you review the section about creating a range, then the section about how for loops work well with ranges. You should be able to create a range of numbers from 1 to N+1 Now, how to add them together? Create a variable, maybe call it total and assign it a value of 0. Then review the section about "in place" operators If you get stuck, then post your attempt back here for assistance PS: print(total)
11th Feb 2021, 9:16 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Please specify the language and show your attempt also
11th Feb 2021, 6:44 AM
Atul [Inactive]
+ 2
print(sum(list(range(int(input())+1))))
11th Feb 2021, 6:48 AM
[bool left=True;]
[bool left=True;] - avatar