Create a function that calculates the number of different squares in an $n * $n square grid. Check the Resources tab.
numberSquares(2) ➞ 5
numberSquares(4) ➞ 30
numberSquares(5) ➞ 55$n = 0 then the number of squares is 0$n = 1 then the number of squares is 1 + 0 = 1$n = 2 then the number of squares is 2^2 + 1 = 4 + 1 = 5$n = 3 then the number of squares is 3^2 + 5 = 9 + 5 = 14As you can see, for each value of $n the number of squares is $n squared + the number of squares from the previous value of $n.