← Back to challenges

Summing the Squares

PythonHardloopsnumberslanguage_fundamentalsmath

Instructions

Create a function that takes a number n and returns the sum of all square numbers up to and including n.

squares_sum(3) ➞ 14
# 1² + 2² + 3² =
# 1 + 4 + 9 =
# 14

Examples

squares_sum(3) ➞ 14

squares_sum(12) ➞ 650

squares_sum(13) ➞ 819

Notes

Remember that n is included in the total.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Reverse Titling