This problem was mentioned in passing in a reading and it piqued my curiosity.
I'm not sure where to start. Any pointers? (perhaps square root was meant?)
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It only takes a minute to sign up.Sign up to join this community
You can determine the square of any real number $n$ by adding the square of $(n-1)$, plus $n-1$, plus $n$. The formula is $n^2 = (n-1)^2 + (n-1) + n$ . E.g.
to find the square of $4$, add the square of $3$, plus $3$, plus $4$ or $9+3+4 = 16$ to find the square of $9$, add the square of $8$, plus $8$, plus $9$ or $64+8+9 = 81$
While you could code a nifty recursive function to determine the square of $n-1$, most systems limit levels of recursion so you will encounter an error when you reach the limit, thus limiting the starting number range. Better to use a loop.
Also, if you're nit-picking, this formula uses subtraction and the original problem mentioned using only addition. In that case, add $a-1$ to $n$ and you should be in conformation with the restriction to only use addition.