105. Sum of Squares
Core1000 ms256 MBSolved by 0%
Print the sum of the squares of the first n natural numbers:
1² + 2² + 3² + ... + n²
Look at the constraint before you write a loop.
Constraints - `1 ≤ n ≤ 1000000000`
Input
A single line containing one integer n.
Output
Print one integer, the sum of the squares of 1 to n.
Input3
Output14
Noteis a small case you can check by hand
Input1
Output1
Noteis the smallest input, where the answer is n itself
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.