Skip to content
CampusEduX

Sum 1..N with i++

Easyjava
Learn the Concept: Unary Operators

Use a counter and the ++ operator in a loop to add up every integer from 1 to N.

Input: one integer N.

Output: one line — the sum 1 + 2 + ... + N.

Related Problems

Input (stdin)

Output

Run your code to see output here...