can someone explain to me why the result code of the exercise "sum of consecutive numbers" in Python for Beginners? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

can someone explain to me why the result code of the exercise "sum of consecutive numbers" in Python for Beginners?

This is the code: N = int(input()) nums = int(N*(N+1)/2) print(nums) I looked for it because I didn't understand it, and i still don't get it.

3rd Dec 2021, 7:02 PM
Sebastiancode
2 Answers
+ 1
It's a maths formulae for finding sum of n consecutive numbers is n*(n+1)/2
3rd Dec 2021, 7:18 PM
Jayakrishna 🇮🇳
+ 1
I got it now, thanks 🤝
3rd Dec 2021, 7:34 PM
Sebastiancode