Treasure Total (Loops)

Read n and print the sum 1 + 2 + … + n using a loop.

Input: One integer n (0 to 100000).

Output: The sum.

Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Keep a running total. The answer can exceed 32-bit integers.

More Loops practice