This site is supported by donations to The OEIS Foundation.

# Pythagorean triples

(Redirected from Pythagorean triple)

Pythagorean triples are triples of positive integers $\scriptstyle (a,\, b,\, c) \,$ such that

$c^2 = a^2 + b^2,\, a < b < c. \,$

Pythagorean triples $\scriptstyle (a,\, b,\, c) \,$ such that GCD$\scriptstyle (a,\, b,\, c) \,$ = 1 are called primitive Pythagorean triples. If a Pythagorean triple $\scriptstyle (a,\, b,\, c) \,$ is not primitive, it is possible to use it to find a primitive triple $\scriptstyle (a',\, b',\, c') \,$ through division of $\scriptstyle (a,\, b,\, c) \,$ by GCD$\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.

## Formulae

$c^2 = a^2 + b^2,\, a < b < c, \,$

if and only if

$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 couple of restrictions on the pairs of integers.

Theorem PYT. In order for positive integers r and s to give x = r2s2, y = 2rs, z = r2 + s2 that form a primitive solution to x2 + y2 = z2, it is necessary that gcd(r,s) = 1 and that one of r and s be even.

Proof. First we verify that r and s give a solution as prescribed by expanding x2 + y2 = z2 thus: (r2s2)2 + (2rs)2 = (r2 + s2)2 and then (r4 + s4 − 2r2s2) + 4r2s2 = r4 + s4 + 2r2s2. If gcd(r,s) > 1, that means there is a prime p such that p | r and p | s. Then x = (pa)2 − (pb)2, y = 2p2ab, z = (pa)2 + (pb)2. Dividing out p2, we obtain $\scriptstyle u \,=\, \frac{x}{p^2} \,=\, a^2 - b^2$, $\scriptstyle v \,=\, \frac{y}{p^2} \,=\, 2ab$ and $\scriptstyle w \,=\, \frac{z}{p^2} \,=\, a^2 + b^2$, and therefore u2 + v2 = w2 = a4 + b4 + 2a2b2, which means x,y,z is not a primitive solution. If gcd(r,s) = 1 and both r and s are odd, then, since the difference of two odd numbers is even, gcd(x,y) = gcd(r2s2,2rs) = 2, and also gcd(x,z) = gcd(r2s2,r2 + s2) = 2, which means that x,y,z are all even and we can divide out p = 2. That leaves us just the case gcd(r,s) = 1 with either r or s even and the other odd. Now we can be certain that x = r2s2 is odd while y = 2rs is at least doubly even, regardless of which of r or s is even. Furthermore, gcd(x,y) = 1 because x is divisible by neither r nor s, while y is divisible by both. Likewise with z = r2 + s2, we see that it is coprime to x since x = z − 2s2 or z = x + 2s2, and z is also coprime to y, which is even and divisible by both r and s, confirming that x,y,z is indeed a primitive Pythagorean triple, and that it could only be obtained with coprime r and 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

A046083 The smallest member $\scriptstyle a \,$ of the Pythagorean triples $\scriptstyle (a,\, b,\, c) \,$ ordered by increasing $\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, ...}

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, ...}

A046084 The middle member $\scriptstyle b \,$ of the Pythagorean triples $\scriptstyle (a,\, b,\, c) \,$ ordered by increasing $\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, ...}

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, ...}

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 $\scriptstyle c \,$ of the Pythagorean triples $\scriptstyle (a,\, b,\, c) \,$ ordered by increasing $\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, ...}

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, ...}