Practice · 1 of 5
Sum with a for loop
CHALLENGE
Difficulty: beginner+25 XP
Implement int sumTo(int n): return 1 + 2 + ... + n using a loop (not the closed-form formula).
Press Submit to check your solution.
Back to lesson: Practice: Loop rep
Practice · 1 of 5
Implement int sumTo(int n): return 1 + 2 + ... + n using a loop (not the closed-form formula).
Back to lesson: Practice: Loop rep