A Pythagorean triple consists of three positive integers , , and , such that . Such a triple is commonly written , a well-known example is . If is a Pythagorean triple, then so is for any positive integer . A triangle whose side lengths are a Pythagorean triple is a right triangle and called a Pythagorean triangle.

A primitive Pythagorean triple is one in which , and are coprime (that is, they have no common divisor larger than 1). For example, is a primitive Pythagorean triple whereas is not. Every Pythagorean triple can be scaled to a unique primitive Pythagorean triple by dividing by their greatest common divisor. Conversely, every Pythagorean triple can be obtained by multiplying the elements of a primitive Pythagorean triple by a positive integer (the same for the three elements).

The name is derived from the Pythagorean theorem, stating that every right triangle has side lengths satisfying the formula ; thus, Pythagorean triples describe the three integer side lengths of a right triangle. However, right triangles with non-integer sides do not form Pythagorean triples. For instance, the triangle with sides and is a right triangle, but is not a Pythagorean triple because the square root of 2 is not an integer. Moreover, and do not have an integer common multiple because is irrational.

Pythagorean triples have been known since ancient times. The oldest known record comes from Plimpton 322, a Babylonian clay tablet from about 1800 BC, written in a sexagesimal number system.

When searching for integer solutions, the equation is a Diophantine equation. Thus Pythagorean triples are among the oldest known solutions of a nonlinear Diophantine equation.

Examples

There are 16 primitive Pythagorean triples of numbers up to 100: {| class="wikitable" style="text-align:right;" |- | (3, 4, 5) | (5, 12, 13) | (8, 15, 17) | (7, 24, 25) |- | (20, 21, 29) | (12, 35, 37) | (9, 40, 41) | (28, 45, 53) |- | (11, 60, 61) | (16, 63, 65) | (33, 56, 65) | (48, 55, 73) |- | (13, 84, 85) | (36, 77, 85) | (39, 80, 89) | (65, 72, 97) |} Other small Pythagorean triples such as (6, 8, 10) are not listed because they are not primitive; for instance (6, 8, 10) is a multiple of (3, 4, 5).

Each of these points (with their multiples) forms a radiating line in the scatter plot to the right.

These are the remaining primitive Pythagorean triples of numbers up to 300: {| class="wikitable" style="text-align:right;" |- | (20, 99, 101) | (60, 91, 109) | (15, 112, 113) | (44, 117, 125) |- | (88, 105, 137) | (17, 144, 145) | (24, 143, 145) | (51, 140, 149) |- | (85, 132, 157) | (119, 120, 169) | (52, 165, 173) | (19, 180, 181) |- | (57, 176, 185) | (104, 153, 185) | (95, 168, 193) | (28, 195, 197) |- | (84, 187, 205) | (133, 156, 205) | (21, 220, 221) | (140, 171, 221) |- | (60, 221, 229) | (105, 208, 233) | (120, 209, 241) | (32, 255, 257) |- | (23, 264, 265) | (96, 247, 265) | (69, 260, 269) | (115, 252, 277) |- | (160, 231, 281) | (161, 240, 289) | (68, 285, 293)

Generating a triple

+ Euclid's formula = = : a = b = c =

Euclid's formula is a fundamental formula for generating Pythagorean triples given an arbitrary pair of integers and with . The formula states that the integers

form a Pythagorean triple. For example, the integers

generate the primitive triple (3, 4, 5):

The triple generated by Euclid's formula is primitive if and only if and are coprime and exactly one of them is even. When both and are odd, then , , and will be even, and the triple will not be primitive; however, dividing , , and by 2 will yield a primitive triple when and are coprime.

Every primitive triple arises (after the exchange of and , if is even) from a unique pair of coprime numbers , , one of which is even. It follows that there are infinitely many primitive Pythagorean triples. This relationship of , and to and from Euclid's formula is referenced throughout the rest of this article.

Despite generating all primitive triples, Euclid's formula does not produce all triples—for example, (9, 12, 15) cannot be generated using integer and . This can be remedied by inserting an additional parameter to the formula: every Pythagorean triple is generated uniquely by

where , , and are positive integers with , and with and coprime and not both odd.

That these formulas generate Pythagorean triples can be verified by expanding using elementary algebra and verifying that the result equals . Since every Pythagorean triple can be divided through by some integer to obtain a primitive triple, every triple can be generated uniquely by using the formula with and to generate its primitive counterpart and then multiplying through by as in the last equation.

Choosing and from certain integer sequences gives interesting results. For example, if and are consecutive Pell numbers, and will differ by 1.

Many formulas for generating triples with particular properties have been developed since the time of Euclid.

Proof of Euclid's formula

That satisfaction of Euclid's formula by a, b, c is sufficient for the triangle to be Pythagorean is apparent from the fact that for positive integers and , , the , , and given by the formula are all positive integers, and from the fact that

A proof of the necessity that a, b, c be expressed by Euclid's formula for any primitive Pythagorean triple is as follows. All such primitive triples can be written as where and , , are coprime. Thus , , are pairwise coprime (if a prime number divided two of them, it would be forced also to divide the third one). As and are coprime, at least one of them is odd. If we suppose that is odd, then is even and is odd (if both and were odd, would be even, and would be a multiple of 4, while would be congruent to 2 modulo 4, as an odd square is congruent to 1 modulo 4).

From assume is odd. We obtain and hence Then Since is rational, we set it equal to in lowest terms. Thus being the reciprocal of Then solving

for and gives

As is fully reduced, and are coprime, and they cannot both be even. If they were both odd, the numerator of would be a multiple of 4 (because an odd square is congruent to 1 modulo 4), and the denominator 2mn would not be a multiple of 4. Since 4 would be the minimum possible even factor in the numerator and 2 would be the maximum possible even factor in the denominator, this would imply to be even despite defining it as odd. Thus one of and is odd and the other is even, and the numerators of the two fractions with denominator 2mn are odd. Thus these fractions are fully reduced (an odd prime dividing this denominator divides one of and but not the other; thus it does not divide ). One may thus equate numerators with numerators and denominators with denominators, giving Euclid's formula with and coprime and of opposite parities.

A longer but more commonplace proof is given in Maor (2007)Maor, Eli, The Pythagorean Theorem, Princeton University Press, 2007: Appendix B. and Sierpiński (2003). Another proof is given in , as an instance of a general method that applies to every homogeneous Diophantine equation of degree two.

Interpretation of parameters in Euclid's formula

Suppose the sides of a Pythagorean triangle have lengths , , and , and suppose the angle between the leg of length and the hypotenuse of length is denoted as . Then and the full-angle trigonometric values are , , and .

A variant The following variant of Euclid's formula is sometimes more convenient, as being more symmetric in and (same parity condition on and ).

If and are two odd integers such that , then

are three integers that form a Pythagorean triple, which is primitive if and only if and are coprime. Conversely, every primitive Pythagorean triple arises (after the exchange of and , if is even) from a unique pair of coprime odd integers.

Not exchanging a and b In the presentation above, it is said that all Pythagorean triples are uniquely obtained from Euclid's formula "after the exchange of a and b, if a is even". Euclid's formula and the variant above can be merged as follows to avoid this exchange, leading to the following result.

Every primitive Pythagorean triple can be uniquely written

where and are positive coprime integers, and if and are both odd, and otherwise. Equivalently, if is odd, and if is even.

Elementary properties of primitive Pythagorean triples

General properties

The properties of a primitive Pythagorean triple with (without specifying which of or is even and which is odd) include: At most one of , , is a square.For the nonexistence of solutions where and are both square, originally proved by Fermat, see . For the other case, in which is one of the squares, see . The area of a Pythagorean triangle cannot be the square or twice the square of an integer. Exactly one of , is divisible by 2 (is even), and the hypotenuse is always odd. Exactly one of , is divisible by 3, but never . Exactly one of , is divisible by 4, but never (because is never even). Exactly one of , , is divisible by 5. The largest number that always divides abc is 60. Any odd number of the form , where is an integer and , can be the odd leg of a primitive Pythagorean triple. See almost-isosceles primitive Pythagorean triples section below. However, only even numbers divisible by 4 can be the even leg of a primitive Pythagorean triple. This is because Euclid's formula for the even leg given above is and one of or must be even. The hypotenuse (which is always odd) is the sum of two squares. This requires all of its prime factors to be primes of the form .. Therefore, c is of the form . A sequence of possible hypotenuse numbers for a primitive Pythagorean triple can be found at . The area is a congruent numberThis follows immediately from the fact that ab is divisible by twelve, together with the definition of congruent numbers as the areas of rational-sided right triangles. See e.g. . divisible by 6. Only two sides of a primitive Pythagorean triple can be simultaneously prime because by Euclid's formula for generating a primitive Pythagorean triple, one of the legs must be composite and even. However, only one side can be an integer of perfect power because if two sides were integers of perfect powers with equal exponent it would contradict the fact that there are no integer solutions to the Diophantine equation , with , and being pairwise coprime.H. Darmon and L. Merel. Winding quotients and some variants of Fermat’s Last Theorem, J. Reine Angew. Math. 490 (1997), 81–100. There are no Pythagorean triangles in which the hypotenuse and one leg are the legs of another Pythagorean triangle; this is one of the equivalent forms of Fermat's right triangle theorem. No primitive Pythagorean triangle has an integer altitude from the hypotenuse; that is, every primitive Pythagorean triangle is indecomposable. The set of all primitive Pythagorean triples forms a rooted ternary tree in a natural way; see Tree of primitive Pythagorean triples. Neither of the acute angles of a Pythagorean triangle can be a rational number of degrees. (This follows from Niven's theorem.)

Special cases

In addition, special Pythagorean triples with certain additional properties can be guaranteed to exist: Every integer greater than 2 that is not congruent to 2 mod 4 (in other words, every integer greater than 2 which is not of the form ) is part of a primitive Pythagorean triple. (If the integer has the form , one may take and in Euclid's formula; if the integer is , one may take and .) Every integer greater than 2 is part of a primitive or non-primitive Pythagorean triple. For example, the integers 6, 10, 14, and 18 are not part of primitive triples, but are part of the non-primitive triples , and .