Find a general method to find particular solutions where the sum of the squares of two consecutive integers is equal to the square of another integer Question:  If the sum  of the squares of two consecutive integers is equal to the square of another integer, then find a general method to find particular solutions.  E.g., $27304196^2+27304197^2=38613965^2$.
I tried to figure out other solutions such as $3^2+4^2=5^2$ and $20^2+21^2=29^2$, but I don't know how to find a method for general solutions.
Can anybody help me
 A: If $n^2+(n+1)^2=k^2$, then $2n^2+2n+1=k^2$, so $(2n+1)^2=4n^2+4n+1=2k^2-1$.
So we are looking for solutions to the negative Pell equation
$(2n+1)^2-2k^2=-1$,
which are $2n+1=1, 7, 41, 239, 1393, 8119, 47321, 275807, 1607521, 9369319,$
$54608393,  ...,$ listed in OEIS.
A: For $A^2+B^2=C^2:\space B=A\pm1\quad$ the $C$-values are the odd Pell numbers  $(5,29,169,985\cdots)$ as shown in A000129
and the triples $T_n$ that contain them can be generate sequentially by the formula below with a seed of $\quad T_0=(0,0,1)$
$$A_{n+1}=3A_n+2C_n+1\qquad B_{n+1}=3A_n+2C_n+2\qquad C_{n+1}=4A_n+3C_n+2$$
For example, it generates the following
$$T_1=(3,4,5)\quad T_2=(20,21,29)\quad T_3=(119,120,169)\quad T_4=(697,696,985)$$
They may also be generated directly using Euclid's formula
$$\text{where} \qquad A=m^2-k^2 \qquad B=2mk \qquad C=m^2+k^2\quad \text{and}$$
\begin{equation}
 m_n= \frac{(1 + \sqrt{2})^{n+1} - (1 - \sqrt{2})^{n+1}}{2\sqrt{2}}\qquad \qquad\qquad
 k_n= \frac{(1 + \sqrt{2})^n - (1 - \sqrt{2})^n}{2\sqrt{2}}
 \end{equation}
For example
\begin{align*}
 \frac{(1 + \sqrt{2})^{2} - (1 - \sqrt{2})^{2}}{2\sqrt{2}}=2 \qquad & 
     \frac{(1 + \sqrt{2})^1 - (1 - \sqrt{2})^1}{2\sqrt{2}}=1 \\ 
&\qquad\qquad   F(2,1)=(3,4,5)\\    
 \frac{(1 + \sqrt{2})^{3} - (1 - \sqrt{2})^{3}}{2\sqrt{2}}=5 \qquad &
     \frac{(1 + \sqrt{2})^2 - (1 - \sqrt{2})^2}{2\sqrt{2}}=2 \\
& \qquad\qquad  F(5,2)=(21,20,29)\\
  \frac{(1 + \sqrt{2})^{4} - (1 - \sqrt{2})^{4}}{2\sqrt{2}}=12 \qquad & 
      \frac{(1 + \sqrt{2})^3 - (1 - \sqrt{2})^3}{2\sqrt{2}}=5 \\ 
&\qquad\qquad  F(12,5)=(119,120,169)\\ 
 \frac{(1 + \sqrt{2})^{5} - (1 - \sqrt{2})^{5}}{2\sqrt{2}}=29 \qquad &
     \frac{(1 + \sqrt{2})^4 - (1 - \sqrt{2})^4}{2\sqrt{2}}=12 \\ 
&\qquad\qquad  F(29,12)=(697,696,985)
 \end{align*}
A: We want to find all $x,y \in \mathbb N$ such that $x^2+(x+1)^2=y^2$. Multiplying both sides by $2$ and rearranging gives
$$ (2x+1)^2 - 2y^2 = -1. $$
This is a Pell equation:
\begin{equation} \tag{Pell} 
X^2 - dY^2 = \pm 1, 
\end{equation}
where $d>0$ and squarefree. All solutions in integer pairs $(X,Y)$ can be obtained from the fundamental unit ${\epsilon}_0$ in the ring of integers ${\mathscr O}_K$ in $K={\mathbb Q}(\sqrt{d})$. It turns out that
$$ {\mathscr O}_K = \begin{cases} {\mathbb Z}[\sqrt{d}] & \:\mbox{if}\: d \not\equiv 1\pmod{4}; \\ {\mathbb Z}\left[1,\frac{1+\sqrt{d}}{2}\right] & \:\mbox{if}\: d \equiv 1\pmod{4}. \end{cases} $$
Solutions $(X,Y)$ to eqn. (Pell) correspond to units in ${\mathscr O}_K$. Units are the invertible elements in the ring. The norm function ${\mathcal N}: {\mathscr O}_K \to \mathbb Z$ given by
$$ {\mathcal N}(a+b\sqrt{d}) = (a+b\sqrt{d})(a-b\sqrt{d}) = a^2-db^2 $$
is multiplicative: ${\mathcal N}(\alpha\beta)={\mathcal N}(\alpha) \cdot {\mathcal N}(\beta)$. Thus, $\alpha$ is a unit if and only if ${\mathcal N}(\alpha)=\pm 1$.
The problem of solving eqn. (Pell) is that of determining units in ${\mathscr O}_K$. The set of units form a cyclic group, upto sign. The generator of this group is called the fundamental unit, ${\epsilon}_0$, and is characterized as the smallest unit $>1$. Thus, the set of all units in ${\mathscr O}_K$ is
$$ U({\mathscr O}_K) = \{ \pm {\epsilon}_0^n: n \in \mathbb Z\}. $$
Solutions with $(X,Y)$ in the first quadrant correspond to $+{\epsilon}_0^n$, with $n>0$. Solutions with $(X,Y)$ in the other three quadrants arise out of choosing whether $n>0$ or $n<0$ and out of the sign $+$ or $-$ to multiply by.
Let us look for solutions with $X>0$ and $Y>0$. The fundamental unit ${\epsilon}_0$ is computed from the continued fraction of $\sqrt{d}$, which we know has the special form
$$ \sqrt{d} = \langle a_0; \overline{a_1,\ldots,a_{\ell-1},2a_0} \rangle, $$
where the sequence $a_1,\ldots,a_{\ell-1}$ is a palindrome - it reads the same left to right as right to left.
Now the fundamental unit is given by
$$ {\epsilon}_0 = X + Y\sqrt{d}, $$
where
$$ \dfrac{X}{Y} = \langle a_0; a_1, \ldots, a_{\ell-1} \rangle. $$
Thus, ${\mathcal N}({\epsilon}_0)=\pm 1$. In fact, it turns out that ${\mathcal N}({\epsilon}_0)=(-1)^{\ell}$. Note that $\ell$ denotes the length of the periodic part of the continued fraction for $\sqrt{d}$.
The eqn. (Pell) with $+1$ always has infinitely many solutions; the one with $-1$ sign either has no solution or infinitely many solutions.
$\bullet$ If ${\mathcal N}({\epsilon}_0)=1$, all solutions $(X,Y)$ with $X>0$ and $Y>0$ for the eqn. (Pell) with $+1$ may be derived from $X_n+Y_n\sqrt{d}={\epsilon}^n$, $n \ge 1$. There is no solution corresponding to $-1$.
$\bullet$ If ${\mathcal N}({\epsilon}_0)=-1$, all solutions $(X,Y)$ with $X>0$ and $Y>0$ for the eqn. (Pell) with $+1$ may be derived from $X_n+Y_n\sqrt{d}={\epsilon}^n$, $n$ even, $n \ge 1$; those corresponding to the eqn. (Pell) with $-1$ may be derived from $X_n+Y_n\sqrt{d}={\epsilon}^n$, $n$ odd, $n \ge 1$.
That is all the theory I will write for now.
To solve $X^2-2Y^2=-1$ we must first compute the continued fraction of $\sqrt{2}$:
$$ \sqrt{2} = \langle 1; \overline{2} \rangle. $$
Thus, ${\epsilon}_0=1+\sqrt{2}$. Note that ${\mathcal N}({\epsilon}_0)=-1$, either by definition of norm or from $\ell=1$. Hence, all solutions $(X,Y)$ with $X>0$ and $Y>0$ are computed from
$$ X_n + Y_n\sqrt{2} = (1+\sqrt{2})^n, \quad n \:\text{odd}, n \ge 1. $$
Since $(1+\sqrt{2})^2=3+2\sqrt{2}$, we have
$$ X_{n+2}+Y_{n+2}\sqrt{2} = (3+2\sqrt{2})(X_n+Y_n\sqrt{2}) = (3X_n+4Y_n)+(2X_n+3Y_n)\sqrt{2}, $$
so that
$$ X_{n+2} = 3X_n+4Y_n, \quad Y_{n+2} = 2X_n+3Y_n, \quad n \:\text{odd}, n \ge 1. $$
Finally, recall that $x=\frac{X-1}{2}$ and $y=Y$. $\blacksquare$
