Skip to main content

Practice · 5 of 6

Special Sum

CHALLENGE
Difficulty: beginner+25 XP

**Description:** Given n, print S = 1^2 + 2^2 + … + n^2 (squares sum). **Input:** One integer n (1 ≤ n ≤ 10^6). **Output:** One integer S. (It can reach ~3.3·10^17 — pick the right type.) **Example:** 3 → 1 + 4 + 9 = 14.

Back to lesson: Practice: Loop Patterns Set