Dsa
Math
Medium
Sum of Squares
Calculate the sum of the squares of the first n natural numbers.
For example, given the input:
3
The output should be:
14 (because 1^2 + 2^2 + 3^2 = 14).
Input format:
- A single integer n (1 ≤ n ≤ 10000).
Output format:
- A single integer representing the sum of squares of the first n natural numbers.
Key concepts
mathsummation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now