Sum of Squares up to N

Given a non-negative integer n, return 1² + 2² + ... + n². When n is 0, the range is empty and the answer is 0.

Given a non-negative integer `n`, return `1² + 2² + ... + n²`. When `n` is `0`, the range is empty and the answer is `0`.

- `0 <= n <= 100` - The answer fits within a 32-bit signed integer.

Example 1: input n = 3; output 14. 1² + 2² + 3² = 14.

Example 2: input n = 0; output 0. The range has no terms.

Example 3: input n = 5; output 55. 1 + 4 + 9 + 16 + 25 = 55.

Category: Math. Topic: math. Difficulty: Easy. Patterns: math.