This site is supported by donations to The OEIS Foundation.

# Pythagorean triples

A Pythagorean triple is a triple of positive integers ${\displaystyle \scriptstyle (a,\,b,\,c)\,}$ which represent the side lengths of a Pythagorean triangle, i.e.

${\displaystyle a^{2}+b^{2}=c^{2},\quad a

where ${\displaystyle a}$ and ${\displaystyle b}$ are the leg (short and long, respectively) lengths of the right triangle and ${\displaystyle c}$ is the hypotenuse length.

Pythagorean triples ${\displaystyle \scriptstyle (a,\,b,\,c)\,}$ such that GCD${\displaystyle \scriptstyle (a,\,b,\,c)\,}$ = 1 are called primitive Pythagorean triples. If a Pythagorean triple ${\displaystyle \scriptstyle (a,\,b,\,c)\,}$ is not primitive, it is possible to use it to find a primitive triple ${\displaystyle \scriptstyle (a',\,b',\,c')\,}$ through division of ${\displaystyle \scriptstyle (a,\,b,\,c)\,}$ by GCD${\displaystyle \scriptstyle (a,\,b,\,c)\,}$. For example, 24, 32, 40 is not a primitive triple, but dividing each number by 8 it leads to the primitive triple 3, 4, 5.

## Hypotenuse numbers

Hypotenuse numbers are positive integers such their square is the sum of 2 distinct nonzero squares, hence the hypotenuse of a Pythagorean triangle.

## Formulae

${\displaystyle a^{2}+b^{2}=c^{2},\,a

if and only if

${\displaystyle c^{2}={\frac {m^{2}+n^{2}}{2}},\,m=b-a,\,n=b+a.\,}$

This provides a way to obtain all Pythagorean triples, primitive and otherwise, by iterating through pairs of integers. To obtain just the primitive Pythagorean triples requires just a few restrictions on the pairs of integers.

Theorem PYT.

In order for positive integers ${\displaystyle r}$ and ${\displaystyle s}$ to give ${\displaystyle x=r^{2}-s^{2}}$, ${\displaystyle y=2rs}$, ${\displaystyle z=r^{2}+s^{2}}$ that form a primitive solution to ${\displaystyle x^{2}+y^{2}=z^{2}}$, it is necessary that ${\displaystyle \gcd(r,s)=1}$ and that one of ${\displaystyle r}$ and ${\displaystyle s}$ be even.

Proof. First we verify that ${\displaystyle r}$ and ${\displaystyle s}$ give a solution as prescribed by expanding ${\displaystyle x^{2}+y^{2}=z^{2}}$ thus: ${\displaystyle (r^{2}-s^{2})^{2}+(2rs)^{2}=(r^{2}+s^{2})^{2}}$ and then ${\displaystyle (r^{4}+s^{4}-2r^{2}s^{2})+4r^{2}s^{2}=r^{4}+s^{4}+2r^{2}s^{2}}$. If ${\displaystyle \gcd(r,s)>1}$, that means there is a prime ${\displaystyle p}$ such that ${\displaystyle p|r}$ and ${\displaystyle p|s}$. Then ${\displaystyle x=(pa)^{2}-(pb)^{2}}$, ${\displaystyle y=2p^{2}ab}$, ${\displaystyle z=(pa)^{2}+(pb)^{2}}$. Dividing out ${\displaystyle p^{2}}$, we obtain ${\displaystyle \scriptstyle u\,=\,{\frac {x}{p^{2}}}\,=\,a^{2}-b^{2}}$, ${\displaystyle \scriptstyle v\,=\,{\frac {y}{p^{2}}}\,=\,2ab}$ and ${\displaystyle \scriptstyle w\,=\,{\frac {z}{p^{2}}}\,=\,a^{2}+b^{2}}$, and therefore ${\displaystyle u^{2}+v^{2}=w^{2}=a^{4}+b^{4}+2a^{2}b^{2}}$, which means ${\displaystyle x,y,z}$ is not a primitive solution.

If ${\displaystyle \gcd(r,s)=1}$ and both ${\displaystyle r}$ and ${\displaystyle s}$ are odd, then, since the difference of two odd numbers is even, ${\displaystyle \gcd(x,y)=\gcd(r^{2}-s^{2},2rs)=2}$, and also ${\displaystyle \gcd(x,z)=\gcd(r^{2}-s^{2},r^{2}+s^{2})=2}$, which means that ${\displaystyle x,y,z}$ are all even and we can divide out ${\displaystyle p=2}$. That leaves us just the case ${\displaystyle \gcd(r,s)=1}$ with either ${\displaystyle r}$ or ${\displaystyle s}$ even and the other odd. Now we can be certain that ${\displaystyle x=r^{2}-s^{2}}$ is odd while ${\displaystyle y=2rs}$ is at least doubly even, regardless of which of ${\displaystyle r}$ or ${\displaystyle s}$ is even. Furthermore, ${\displaystyle \gcd(x,y)=1}$ because ${\displaystyle x}$ is divisible by neither ${\displaystyle r}$ nor ${\displaystyle s}$, while ${\displaystyle y}$ is divisible by both. Likewise with ${\displaystyle z=r^{2}+s^{2}}$, we see that it is coprime to ${\displaystyle x}$ since ${\displaystyle x=z-2s^{2}}$ or ${\displaystyle z=x+2s^{2}}$, and ${\displaystyle z}$ is also coprime to ${\displaystyle y}$, which is even and divisible by both ${\displaystyle r}$ and ${\displaystyle s}$, confirming that ${\displaystyle x,y,z}$ is indeed a primitive Pythagorean triple, and that it could only be obtained with coprime ${\displaystyle r}$ and ${\displaystyle s}$, one of which is even, as specified by the theorem.

So, for example, the pair 5, 2 will give the primitive triple 21, 20, 29, while 5, 3 gives the triple 16, 30, 34, which can be 'reduced' to the primitive triple 8, 15, 17.

## Sequences

### Sequences (legs)

A118905 Sum of legs of Pythagorean triangles (without multiple entries).

{7, 14, 17, 21, 23, 28, 31, 34, 35, 41, 42, 46, 47, 49, 51, 56, 62, 63, 68, 69, 70, 71, 73, 77, 79, 82, 84, 85, 89, 91, 92, 93, 94, 97, 98, 102, 103, 105, 112, 113, 115, 119, 123, 124, 126, 127, 133, 136, ...}

#### Sequences (short legs)

A020884 Ordered short legs of primitive Pythagorean triangles.

{3, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17, 19, 20, 20, 21, 23, 24, 25, 27, 28, 28, 29, 31, 32, 33, 33, 35, 36, 36, 37, 39, 39, 40, 41, 43, 44, 44, 45, 47, 48, 48, 49, 51, 51, 52, 52, 53, 55, 56, 57, 57, 59, 60, ...}

A009004 Ordered short legs of Pythagorean triangles.

{3, 5, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 15, 16, 16, 17, 18, 18, 19, 20, 20, 20, 21, 21, 21, 22, 23, 24, 24, 24, 24, 25, 25, 26, 27, 27, 27, 28, 28, 28, 29, 30, 30, 30, 31, 32, 32, 32, 33, 33, 33, ...}

A046083 The smallest member ${\displaystyle \scriptstyle a\,}$ of the Pythagorean triples ${\displaystyle \scriptstyle (a,\,b,\,c)\,}$ ordered by increasing ${\displaystyle \scriptstyle c\,}$.

{3, 6, 5, 9, 8, 12, 15, 7, 10, 20, 18, 16, 21, 12, 15, 24, 9, 27, 30, 14, 24, 20, 28, 33, 40, 36, 11, 39, 33, 25, 16, 32, 42, 48, 24, 45, 21, 30, 48, 18, 51, 40, 36, 13, 60, 39, 54, 35, 57, 65, 60, 28, 20, 48, ...}

#### Sequences (long legs)

A020883 Ordered long legs of primitive Pythagorean triangles.

{4, 12, 15, 21, 24, 35, 40, 45, 55, 56, 60, 63, 72, 77, 80, 84, 91, 99, 105, 112, 117, 120, 132, 140, 143, 144, 153, 156, 165, 168, 171, 176, 180, 187, 195, 208, 209, 220, 221, 224, 231, 240, 247, 252, 253, ...}

A009012 Ordered long legs of Pythagorean triangles.

{4, 8, 12, 12, 15, 16, 20, 21, 24, 24, 24, 28, 30, 32, 35, 36, 36, 40, 40, 42, 44, 45, 45, 48, 48, 48, 52, 55, 56, 56, 60, 60, 60, 60, 63, 63, 64, 68, 70, 72, 72, 72, 72, 75, 76, 77, 80, 80, 80, 84, 84, 84, 84, ...}

A046084 The middle member ${\displaystyle \scriptstyle b\,}$ of the Pythagorean triples ${\displaystyle \scriptstyle (a,\,b,\,c)\,}$ ordered by increasing ${\displaystyle \scriptstyle c\,}$.

{4, 8, 12, 12, 15, 16, 20, 24, 24, 21, 24, 30, 28, 35, 36, 32, 40, 36, 40, 48, 45, 48, 45, 44, 42, 48, 60, 52, 56, 60, 63, 60, 56, 55, 70, 60, 72, 72, 64, 80, 68, 75, 77, 84, 63, 80, 72, 84, 76, 72, 80, 96, 99, ...}

### Sequences (hypotenuse)

A020882 Ordered hypotenuse numbers of primitive Pythagorean triangles (squares are sums of 2 distinct nonzero squares and GCD[a,b,c] = 1).

{5, 13, 17, 25, 29, 37, 41, 53, 61, 65, 65, 73, 85, 85, 89, 97, 101, 109, 113, 125, 137, 145, 145, 149, 157, 169, 173, 181, 185, 185, 193, 197, 205, 205, 221, 221, 229, 233, 241, 257, 265, 265, 269, 277, ...}

A009003 Hypotenuse numbers (squares are sums of 2 distinct nonzero squares).

{5, 10, 13, 15, 17, 20, 25, 26, 29, 30, 34, 35, 37, 39, 40, 41, 45, 50, 51, 52, 53, 55, 58, 60, 61, 65, 68, 70, 73, 74, 75, 78, 80, 82, 85, 87, 89, 90, 91, 95, 97, 100, 101, 102, 104, 105, 106, 109, 110, 111, ...}

A009000 Ordered hypotenuse numbers (squares are sums of 2 distinct nonzero squares). The largest member ${\displaystyle \scriptstyle c\,}$ of the Pythagorean triples ${\displaystyle \scriptstyle (a,\,b,\,c)\,}$ ordered by increasing ${\displaystyle \scriptstyle c\,}$.

{5, 10, 13, 15, 17, 20, 25, 25, 26, 29, 30, 34, 35, 37, 39, 40, 41, 45, 50, 50, 51, 52, 53, 55, 58, 60, 61, 65, 65, 65, 65, 68, 70, 73, 74, 75, 75, 78, 80, 82, 85, 85, 85, 85, 87, 89, 90, 91, 95, 97, 100, 100, ...}