# Sum of two consecutive squares equal square

$N^2 + (N+1)^2 = K^2$, find all solutions for $N<200$

I have done some factoring and also realized that $K=[n\sqrt{2}]+1$ in eventual solutions, where $[x]$ denotes the greatest integer less than.

The problem is from Nordic math competition 1994.

• math.stackexchange.com/questions/1776734/… – individ May 18 '16 at 17:35
• The solutions are $(3,4,5)$, $(20,21,29)$, and $(119,120,169)$, You want to look at the continued-fraction convergents to $1+\sqrt2$. – Lubin May 18 '16 at 18:26

We want solutions to $k^2=n^2+(n+1)^2$. So $(k,n,n+1)$ is a Pythagorean triple. Moreover it is a primitive triple since $n,n+1$ are coprime. So we must be able to write it as $k=a^2+b^2,n=2ab,n+1=a^2-b^2$ for $n$ even or $k=a^2+b^2,n=a^2-b^2,n+1=2ab$ for $n$ odd.
If $n$ is odd, then $a^2-b^2+1=2ab$ and $a>b$, so we have $(a+b)^2-2a^2=1$. If $n$ is even, we have $2ab+1=a^2-b^2$, so $(a+b)^2-2a^2=-1$.
So we need solutions to the Pell equation $r^2-2s^2=\pm1$. The smallest such solution is $(r_1,s_1)=(1,1)$. We generate the others by $r_{n+1}=r_n+2s_n,s_{n+1}=r_n+s_n$. So we get $(3,2),(7,5),(17,12),(41,29)$.
These give the solutions $(k,n)=(5,3),(29,20),(169,119)$, and the next is obviously outside the range.