Summing the Squares

Published by Mubashir Hassan in

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

squaresSum(3) ➞ 14
// 1² + 2² + 3² =
// 1 + 4 + 9 =
// 14 

Examples

squaresSum(3) ➞ 14

squaresSum(12) ➞ 650

squaresSum(13) ➞ 819

Notes

Remember that n is included in the total.

Watch a quick demo on how Edabit works.