Loading...
Loading...
Loading...
An online store numbers its orders 1, 2, 3 and so on. A report needs the sum of the first n order numbers.
Given n, print 1 + 2 + ... + n.
Example
Input
4
Output
10
1 + 2 + 3 + 4 = 10.
Try the problem first. Open one hint at a time.
Use a variable that starts at 0 and collects the total.
Add each number from 1 to n. The stop value of range is not included.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor