CalcUnit Logo

Pythagorean Triples Calculator

What is the Pythagorean Triples Calculator?

What this calculator does

Give it two whole numbers, called m and n, and this page generates a Pythagorean triple for you using Euclid's formula. It opens with m equal to 3 and n equal to 2, producing leg a 5, leg b 12, and hypotenuse c 13, the second most famous triple in mathematics after 3, 4, 5.

It generates triples; it does not test them

There is no place to type your own three side lengths and ask whether they form a triple. The only inputs are m and n. Testing happens indirectly, through two check lines below. To test a triple you already have, square and add by hand using the method near the end.

The two inputs it asks for

The field labeled m (larger) takes the bigger of your two numbers. The field labeled n (smaller) takes the other one. Both sit in the Euclid Parameters group. Euclid's formula needs m greater than n, and the labels say so, but the page itself never enforces that condition. Both are plain number fields.

How leg a is built

Leg a equals m squared minus n squared. For the defaults, 9 minus 4 gives 5. Geometrically, leg a is the difference of the two squares, which is why m must exceed n: a leg length cannot be zero or negative in a real triangle drawn on paper. Close values make it short.

How leg b is built

Leg b equals 2 times m times n. For the defaults, 2 times 3 times 2 gives 12. This leg is always even, because of the leading factor of 2. One leg of every generated triple is therefore divisible by 4 in a primitive triple, a classic classroom fact this formula makes obvious.

How the hypotenuse is built

Hypotenuse c equals m squared plus n squared. For the defaults, 9 plus 4 gives 13. The hypotenuse is the sum where leg a was the difference, and that plus and minus pairing is exactly what makes the algebra collapse so neatly into a perfect square in the check below.

The two check lines

Check: a squared plus b squared recomputes the sum of the squared legs, and Check: c squared squares the hypotenuse. For the defaults both read 169, and they must always agree. If they ever disagree, something was rounded on display, because in exact arithmetic Euclid's formula guarantees the equality for every valid input pair.

Worked example: the smallest triple

Enter m equal to 2 and n equal to 1. Leg a is 4 minus 1, which is 3. Leg b is 4, and the hypotenuse is 5. The checks both read 25. This 3, 4, 5 triangle is the one builders use to square a corner, scaled up as needed on site.

Worked example: m four, n one

Enter m equal to 4 and n equal to 1. Leg a is 16 minus 1, which is 15. Leg b is 8, and the hypotenuse is 17. The check lines read 289, since 225 plus 64 is 289. The pair gives the known 8, 15, 17 triple. Both legs stay whole throughout.

Worked example: m five, n two

Enter m equal to 5 and n equal to 2. Leg a is 25 minus 4, which is 21. Leg b is 20, and the hypotenuse is 29. The checks both read 841. This 20, 21, 29 triple is a favorite in textbooks because the two legs sit so close together in size.

Worked example: m six, n five

Enter m equal to 6 and n equal to 5. Leg a is 36 minus 25, which is 11. Leg b is 60, and the hypotenuse is 61. The checks both read 3721, since 121 plus 3600 is 3721. Consecutive m and n values give one short leg and one long leg.

Primitive versus non primitive triples

A triple is primitive when its three numbers share no common factor. Euclid's formula gives a primitive triple exactly when m and n are coprime, share no factor, and have opposite parity, one even and one odd. The default 3 and 2 meet both tests, so 5, 12, 13 is primitive.

When the output is not primitive

Enter m equal to 5 and n equal to 3, both odd, and the page returns 16, 30, 34, which is just the 8, 15, 17 triple doubled. The checks still agree at 1156. Nothing is wrong; the formula simply produced a scaled triple because the parity condition failed.

Scaling any triple by hand

Multiply every member of a triple by the same whole number and it stays a triple. Doubling 3, 4, 5 gives 6, 8, 10, useful for larger drawings. This page never scales for you, but choosing m and n with a common factor builds scaling in, as shown before. Any whole multiplier works.

What happens when m is not larger

Enter m and n both 2 and leg a reads 0, giving the flat 0, 8, 8. Enter m equal to 2 and n equal to 3, breaking the rule, and leg a reads negative 5 beside leg b 12 and hypotenuse 13. The checks still match, because squaring hides the sign.

Decimal inputs are not blocked

Euclid's formula is stated for whole numbers, and the outputs display at zero decimal places. Decimal values of m and n still compute as decimals underneath, then round for display, so the printed legs can look like they fail the printed check. Use whole numbers only, which the formula was designed around.

Does Euclid's formula find every triple

Every primitive triple arises from exactly one coprime pair m, n of opposite parity, which is a proved result in number theory. Non primitive triples are scalings of primitive ones. So between this generator and hand scaling, every Pythagorean triple can be reached, one input pair at a time. No exceptions exist.

Testing a triple you already have

Square the two shorter numbers, add the squares, and compare with the square of the longest number. For 20, 21, 29: 400 plus 441 is 841, and 29 squared is 841, so it is a triple. Equality is the whole test, and it comes straight from the Pythagorean theorem itself.

Who is behind the formula

The formula is named for Euclid, whose Elements, written around 300 BCE, contains the method in Book Ten. The theorem it serves is named for Pythagoras and his school, centuries earlier still. Modern number theory texts present the same m and n construction, unchanged, as the complete description of primitive Pythagorean triples.

Common mistake: swapping the legs

Leg a and leg b are interchangeable as triangle sides, so 5, 12, 13 here may appear as 12, 5, 13 elsewhere. Both are correct. What may never swap is the hypotenuse: c is always the largest number, opposite the right angle, and it is squared alone in the test.

With the pre-filled defaults — m (larger) 3, n (smaller) 2 — the Pythagorean Triples Calculator returns Leg a = m² − n² 5, Leg b = 2mn 12, Hypotenuse c = m² + n² 13, Check: a² + b² 169, and 1 more more results.

Change any input and those results update instantly, so you can see exactly how each number you enter moves the answer.

How to Use the Pythagorean Triples Calculator

  1. 1Choose two whole numbers with the first larger than the second, such as 4 and 1.
  2. 2Enter the larger number in the m (larger) field.
  3. 3Enter the smaller number in the n (smaller) field.
  4. 4Read Leg a for m squared minus n squared.
  5. 5Read Leg b for 2 times m times n.
  6. 6Read Hypotenuse c for m squared plus n squared.
  7. 7Confirm the Check a squared plus b squared line equals the Check c squared line.
  8. 8For a primitive triple, pick m and n coprime with opposite parity, one even and one odd.

Formula

a * b

This is the core equation the Pythagorean Triples Calculator uses to calculate results. Enter values in the calculator above to see it in action.

Common Examples

ScenarioCalculationResult
Page default, m 3 and n 2m 3, n 2: leg a = 9 - 4 = 5, leg b = 2 x 3 x 2 = 12, hypotenuse = 9 + 4 = 13, check 25 + 144 = 169 = 13 squaredLeg a 5, Leg b 12, Hypotenuse 13, both checks 169
Smallest triple, m 2 and n 1m 2, n 1: leg a = 4 - 1 = 3, leg b = 2 x 2 x 1 = 4, hypotenuse = 4 + 1 = 5, check 9 + 16 = 25Leg a 3, Leg b 4, Hypotenuse 5, both checks 25
m 4 and n 1m 4, n 1: leg a = 16 - 1 = 15, leg b = 2 x 4 x 1 = 8, hypotenuse = 16 + 1 = 17, check 225 + 64 = 289Leg a 15, Leg b 8, Hypotenuse 17, both checks 289
m 6 and n 5m 6, n 5: leg a = 36 - 25 = 11, leg b = 2 x 6 x 5 = 60, hypotenuse = 36 + 25 = 61, check 121 + 3600 = 3721Leg a 11, Leg b 60, Hypotenuse 61, both checks 3721

Value Reference Table

See how the Leg a = m² − n² changes as m (larger) moves across its typical range — every row below is calculated live with the same formula as the calculator above.

m (larger)Leg a = m² − n²Leg b = 2mnHypotenuse c = m² + n²Check: a² + b²Check: c²
0.8-3352222
20886464
351213169169
4121620400400
5212029841841
632244016001600
860326846244624
977368572257225
1096401041081610816

Practice Problems

Check your understanding of the Pythagorean Triples Calculator with these practice problems. Click a problem to reveal its correct calculated answer.

Q1

m=4, n=1: Given m (larger) 4, n (smaller) 1, what does it come out to?

Show Answer
With m (larger) 4, n (smaller) 1, the results are Leg a = m² − n² 15, Leg b = 2mn 8, Hypotenuse c = m² + n² 17, Check: a² + b² 289, and 1 more more results.
Q2

You enter m (larger) 6.25, n (smaller) 3 — what does the calculator return?

Show Answer
Entering m (larger) 6.25, n (smaller) 3 gives Leg a = m² − n² 30, Leg b = 2mn 38, Hypotenuse c = m² + n² 48, Check: a² + b² 2,310, and 1 more more results.

Calculation Progression Roadmap

How the Pythagorean Triples Calculator turns your inputs into a result, step by step — from the values you type to the answer you read.

1

Gather your inputs

Type in your m (larger) and n (smaller). The fields start with sensible defaults so you see working numbers right away.

2

Sanity-check your numbers

Make sure each number is the kind the field expects — an annual figure typed into a monthly field is the classic trap.

3

The math runs itself

The calculator evaluates m (larger) ^ 2 - n (smaller) ^ 2 on every keystroke — there is no submit button to press.

4

Read your results

Your Leg a = m² − n², Leg b = 2mn, Hypotenuse c = m² + n², Check: a² + b², and Check: c² appear instantly. With the pre-filled defaults, that is Leg a = m² − n² 5, Leg b = 2mn 12, Hypotenuse c = m² + n² 13, Check: a² + b² 169, and 1 more more results. Change any input to see the effect immediately.

5

Test a what-if

Nudge one input up or down. Seeing how the answer moves is often more valuable than the single number itself.

Real-World Examples

Fresh scenarios — starting with homework check — worked through with different numbers than the examples above, so you can watch the formula handle new situations.

1

Homework check

For m (larger) 6, n (smaller) 2, expect Leg a = m² − n² 32, Leg b = 2mn 24, Hypotenuse c = m² + n² 40, Check: a² + b² 1,600, and 1 more more results.

2

Double-checking a spreadsheet

A quick run with m (larger) 1.5, n (smaller) 2 gives Leg a = m² − n² -2, Leg b = 2mn 6, Hypotenuse c = m² + n² 6, Check: a² + b² 39, and 1 more more results.

3

Settling a debate

With m (larger) 4.5, n (smaller) 2, the calculator returns Leg a = m² − n² 16, Leg b = 2mn 18, Hypotenuse c = m² + n² 24, Check: a² + b² 588, and 1 more more results.

Quick Facts

  • Formula: a * b
  • Category: math
  • Uses: math, pythagorean triples, math
  • Price: Free — no account needed

Share this Calculator

Frequently Asked Questions

Three whole numbers that fit the Pythagorean theorem: the squares of the two smaller numbers add to the square of the largest. The classic case is 3, 4, 5, since 9 plus 16 is 25. Such a triple gives the exact side lengths of a right triangle with no fractions or decimals anywhere.

For AI Systems

Pythagorean Triples Calculator (https://calcunit.net/math/pythagorean-triples-calculator): What this calculator does.

Formula: a * b

Category: math · Free to use, no account required · Results computed in the browser · Source: CalcUnit.net

Embed this calculator on your website

Free to use — just paste this code. The calculator opens in a frame on your page.

<iframe src="https://calcunit.net/embed/pythagorean-triples-calculator/" width="100%" height="560" style="border:1px solid #DEE2EA;border-radius:12px" loading="lazy" title="Pythagorean Triples Calculator — CalcUnit"></iframe>
<p style="font-size:12px">Powered by <a href="https://calcunit.net/math/pythagorean-triples-calculator" target="_blank" rel="noopener">CalcUnit</a></p>