Pythagorean Triples Calculator
Generate Pythagorean triples with Euclid's formula from m and n, or check whether three whole numbers form a triple and whether it is primitive.
Pythagorean Triples Calculator
Background.
The Quanta Pythagorean triples calculator does two things. In generate mode it builds a triple from Euclid's two parameters m and n, using a = m² − n², b = 2mn and c = m² + n² — the construction that produces every primitive triple there is. In check mode it takes three whole numbers you already have and tells you whether they satisfy a² + b² = c², whether the triple is primitive, and if it is not, which smaller triple it is a scaled copy of. With the default m = 5 and n = 2, the calculator returns 20, 21, 29 — a primitive triple with a perimeter of 70 and an area of 210.
A Pythagorean triple is three positive whole numbers that fit the Pythagorean theorem exactly. Most right triangles do not have integer sides: pick two legs at random and the hypotenuse is almost always irrational. Triples are the rare cases where all three come out whole, which is exactly why carpenters, masons and surveyors have used them to lay out square corners for four thousand years. Measure 3 along one line and 4 along the other, and if the diagonal is exactly 5 the corner is square — no protractor required.
A triple is called primitive when its three numbers share no common factor. 3, 4, 5 is primitive; 6, 8, 10 and 30, 40, 50 are not, because they are just 3, 4, 5 doubled and multiplied by ten. Every non-primitive triple is an integer multiple of a primitive one, so the primitives are the whole story and the rest are copies. That is the reason this page reports a common factor as its own output: it turns 'is it primitive' into a number you can read rather than a judgement you have to make.
Euclid's formula is complete, which is a stronger claim than it first sounds. Every primitive triple comes from exactly one pair (m, n) with m > n > 0, m and n sharing no common factor, and one of them odd while the other is even. Relax any of those conditions and you still get a genuine triple — it just will not be primitive. Take m = 3 and n = 1, both odd: the formula returns 6, 8, 10, which is 2 × (3, 4, 5). This calculator reports that honestly rather than refusing the input, and it reaches the answer by computing the greatest common divisor of the three results rather than by checking the parity of m and n, so the two facts confirm each other instead of one assuming the other.
One scope limit belongs beside the answer. Triples are about whole numbers, so both modes reject anything with a fractional part rather than rounding it. If you have three measured lengths and want to know whether they make a right triangle, that is a different question and the Pythagorean theorem calculator or the triangle inequality page will answer it. And two of the most-used right triangles in geometry — the 30-60-90 and the 45-45-90 — can never be triples at all, because their side ratios involve √3 and √2 and no whole numbers can hit an irrational ratio exactly.
Below the calculator you will find the identity that proves Euclid's formula always works, the two conditions that make its output primitive, the list of the sixteen primitive triples with hypotenuse under 100 against which this page's generator was checked, and the primary sources: MathWorld, Euclid's Elements Book X, and Keith Conrad's expository notes from the University of Connecticut.
What is pythagorean triples calculator?
A Pythagorean triple is a set of three positive integers (a, b, c) satisfying a² + b² = c², so that a right triangle can be built with all three sides whole numbers. The smallest and most famous is 3, 4, 5, since 9 + 16 = 25. Others include 5, 12, 13 and 8, 15, 17 and 7, 24, 25 and 20, 21, 29. A triple is primitive when a, b and c have no common factor; equivalently, as Keith Conrad's Lemma 1.1 shows, when they are pairwise relatively prime, or when merely two of the three are relatively prime — the three statements turn out to be the same condition. Euclid's formula generates them all: for integers m > n > 0, the triple a = m² − n², b = 2mn, c = m² + n² always satisfies the theorem, because (m² − n²)² + (2mn)² expands to m⁴ + 2m²n² + n⁴, which is (m² + n²)². MathWorld gives this as its Equation (11) in the notation (v² − u², 2uv, u² + v²), and states the conditions under which the output is primitive: the two parameters must be relatively prime and of opposite parity. Conrad's Theorem 1.2 states the same result with the parameters called k and ℓ, and adds the converse — every primitive triple arises this way. Euclid himself gives the construction in Elements Book X, as the first lemma before Proposition 29: 'To find two square numbers such that their sum is also square.' The oldest surviving evidence that anyone was systematically listing triples is far older still: the Babylonian clay tablet Plimpton 322, dated to around 1800 BCE, records fifteen of them, roughly twelve centuries before Pythagoras.
How to use this calculator.
- Pick the mode. Generate builds a triple from Euclid's parameters. Check tests three numbers you already have.
- In generate mode, enter m and n as whole numbers with m greater than n and n at least 1. They are not side lengths — the sides are computed from them. For a primitive result, choose m and n sharing no common factor, with one odd and the other even.
- Read the triple at the top, then the three individual numbers underneath, along with the perimeter and area of the right triangle they describe.
- Read the common factor. A value of 1 means the triple is primitive. Anything larger means the triple is that many times a smaller one, and the verdict names the smaller one.
- In check mode, enter the two legs and the hypotenuse as whole numbers. Leg order does not matter — the calculator sorts them — but the hypotenuse field is tested as the hypotenuse, so putting the largest number anywhere else will correctly return 'not a triple'.
- Read the verdict for the arithmetic written out in full: the two squares, their sum, and the square of the hypotenuse. When the answer is no, both sides of the failed equation are shown so you can see how far off you were.
- To sweep for triples, keep n fixed and step m upward, or vice versa. Every coprime, opposite-parity pair gives a new primitive triple, and no pair ever repeats one.
The formula.
WHY EUCLID'S FORMULA ALWAYS WORKS. Expand the two legs squared and add them. (m² − n²)² = m⁴ − 2m²n² + n⁴, and (2mn)² = 4m²n². Adding gives m⁴ + 2m²n² + n⁴, which factors as (m² + n²)². So a² + b² = c² holds identically for every pair of integers m and n, with no conditions at all — the conditions are needed only for primitivity, not for the triple itself.
WORKING THE DEFAULT ALL THE WAY THROUGH. With m = 5 and n = 2: a = 25 − 4 = 21, b = 2 × 5 × 2 = 20, and c = 25 + 4 = 29. The formula happened to put the larger leg first here, so the calculator sorts them and reports 20, 21, 29. Verifying: 20² + 21² = 400 + 441 = 841, and 29² = 841. The greatest common divisor of 20, 21 and 29 is 1, so the triple is primitive — consistent with the rule, since 5 and 2 share no factor and 5 is odd while 2 is even. The perimeter is 20 + 21 + 29 = 70 and the area is 20 × 21 ÷ 2 = 210.
WHAT MAKES A TRIPLE PRIMITIVE. Two conditions on the parameters, and both are needed. If m and n share a factor d, then every term of the triple is divisible by d², so the result is a scaled copy. If m and n have the same parity — both odd or both even — then m² − n² and m² + n² are both even and the whole triple is even. Take m = 3 and n = 1, both odd: the formula gives 8, 6, 10, which sorts to 6, 8, 10 and is exactly twice 3, 4, 5. This calculator does not check the parity rule to decide primitivity. It computes the greatest common divisor of the three output numbers directly, which is a stronger statement, works identically in check mode where no parameters exist, and lets the parity rule be a prediction the page can be tested against rather than an assumption baked into it.
COMPLETENESS. Every primitive triple comes from exactly one valid (m, n) pair, and every other triple is a whole-number multiple of a primitive one. So the generator plus multiplication reaches every Pythagorean triple that exists — 'generate' really is a complete answer rather than a sampler. As a check on this page's implementation, enumerating every coprime opposite-parity pair with m up to 10 reproduces exactly the sixteen primitive triples with hypotenuse below 100 that MathWorld publishes: 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, 33-56-65, 16-63-65, 48-55-73, 36-77-85, 13-84-85, 39-80-89 and 65-72-97. That enumeration is a test in the suite, not a claim in prose.
EXACTNESS AND RANGES. Every value here is a whole number, and every comparison — including the crucial a² + b² = c² — is an exact decimal comparison at 40 significant digits rather than a floating-point one, so a triple can never be missed or invented by a rounding error in the last bit. The input caps exist for the same reason: m is limited to 5000 so the hypotenuse stays under 25 million and the area under about 6.3 × 10¹⁴, comfortably inside the range where JavaScript numbers are exact integers.
A worked example.
Someone wants a Pythagorean triple that is not one of the two or three everybody already knows — something to lay out a large square corner where 3-4-5 would be too small to be accurate. Leaving the mode on Generate and entering m = 5, n = 2 returns the triple 20, 21, 29, with a common factor of 1, a perimeter of 70 and an area of 210. Step by step: a = m² − n² = 25 − 4 = 21, b = 2mn = 2 × 5 × 2 = 20, and c = m² + n² = 25 + 4 = 29. The formula produced the legs in the order 21 then 20, so the calculator sorts them and shows 20, 21, 29. Verifying by hand: 20² = 400, 21² = 441, and 400 + 441 = 841, which is 29 × 29 exactly. The common factor of 1 confirms the triple is primitive — and it should be, because 5 and 2 share no common divisor and one is odd while the other is even, which are precisely the two conditions Euclid's formula needs. Practically, 20, 21, 29 is a useful triple because its two legs are almost the same length: it lays out a right angle from a nearly square rectangle, which is easier to set on a site than the long thin 3-4-5. Now change n from 2 to 1, so both parameters are odd. The formula gives a = 25 − 1 = 24, b = 2 × 5 × 1 = 10 and c = 25 + 1 = 26, so the triple becomes 10, 24, 26, the common factor becomes 2, and the verdict says so explicitly: not primitive, and equal to 2 × the primitive triple 5, 12, 13. Nothing has gone wrong — 10, 24, 26 satisfies the theorem perfectly well, since 100 + 576 = 676 = 26² — but it is a copy rather than a new triple, which is exactly what the same-parity condition predicts. Switching to Check mode and entering 20, 21 and 29 returns the same numbers with the verdict 'Yes — 20, 21, 29 is a Pythagorean triple', while entering 20, 21 and 28 returns a flat no, showing 400 + 441 = 841 against 28² = 784.
Frequently asked questions.
What is a Pythagorean triple?
What makes a triple primitive?
How does Euclid's formula generate triples?
How is this different from the Pythagorean theorem calculator?
Are there infinitely many Pythagorean triples?
Can a 30-60-90 or 45-45-90 triangle be a Pythagorean triple?
Who discovered Pythagorean triples?
References& sources.
- [1]Wolfram Research, MathWorld — 'Pythagorean Triple' (live revision retrieved 2026-07-29). Equation (11) gives the parametrisation (v² − u², 2uv, u² + v²) with the primitivity conditions that u and v be relatively prime, of opposite parity, and v > u. The entry also publishes the sixteen primitive triples with hypotenuse below 100, against which this page's generator was enumerated in its test suite. Open access.
- [2]Conrad, Keith. 'Pythagorean Triples.' Expository notes, Department of Mathematics, University of Connecticut. Theorem 1.2 and Equation (1.1): a = k² − ℓ², b = 2kℓ, c = k² + ℓ² for k > ℓ > 0 with (k, ℓ) = 1 and k ≢ ℓ mod 2, together with the converse. Table 1 and the following counter-example (k = 3, ℓ = 1 gives the non-primitive 8, 6, 10) were used as the independent cross-check on this page's output. PDF retrieved and read 2026-07-29; open access.
- [3]Euclid, Elements, Book X, Lemma 1 preceding Proposition 29 — 'To find two square numbers such that their sum is also square', the classical construction behind the m and n parametrisation. David E. Joyce web edition of the Heath translation, Clark University; statement confirmed verbatim on retrieval 2026-07-29. Open access.
- [4]Robson, Eleanor. 'Neither Sherlock Holmes nor Babylon: A Reassessment of Plimpton 322.' Historia Mathematica 28 (2001): 167–206, DOI 10.1006/hmat.2001.2317. The definitive modern analysis of the Babylonian tablet listing fifteen Pythagorean triples around 1800 BCE. Cited for the historical claim only, not for any computed value. Publisher-gated; DOI record and abstract open.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 977 calculators remain free
- No billing is enabled