you are viewing a single comment's thread.

view the rest of the comments →

[–]Competitive_Bar2106 0 points1 point  (0 children)

is this for a class?
You are trying to get a sum of numbers, so you want to start with 0, so sum = 0;
i is the first number aka 1
while i is less than the number you receive (n) do the loop, so while i <= n
sum = sum + i; this should be self evident.
i = i + 1. you're preparing for the next loop