Sum to N
beginnerUp next
Up next
Output will appear here...
Read an integer n and print the sum of all the whole numbers from 1 to n, including n. If n is 0, the sum is 0.
For an input of 10, a correct solution prints 55.
Tip
Start a total variable at 0 and add to it on each pass of the loop.
No comments yet. Start the discussion.