Pythagorean Triple Generator

Enter integers m and n (m > n ≥ 1) to generate a Pythagorean triple.

Result

21
20
29

How it is calculated

The tool applies Euclid's formula to two whole numbers m and n with m > n ≥ 1:

a = m² − n², b = 2mn, c = m² + n²

These always satisfy a² + b² = c², so they are the two legs and the hypotenuse of a right triangle with whole-number sides. Decimals are rejected, and so is any pair where m is not larger than n or n is below 1. The tool does not check that the triple is primitive. If m and n share a factor, or are both odd, the three numbers will have a common divisor (for m = 5 and n = 3 you get 16, 30, 34, which is 2 times 8, 15, 17).

Worked example

Choose m = 5 and n = 2. Then a = 25 − 4 = 21, b = 2 × 5 × 2 = 20 and c = 25 + 4 = 29. Check: 21² + 20² = 441 + 400 = 841, and 29² = 841. So a triangle with sides 20, 21 and 29 has a right angle. Because 5 and 2 are coprime and of opposite parity, this triple is primitive.

Try this example →

Common mistakes

  • Entering m smaller than or equal to n; the order matters, m must be the larger number.
  • Typing decimals like 2.5, which are rejected. Both inputs must be whole numbers.
  • Assuming every result is a primitive triple. Pairs such as 5 and 3 give 16, 30, 34, which reduces to 8, 15, 17.
  • Expecting every triple to appear from a single pair. Euclid's formula gives primitive ones; non-primitive ones come from multiplying all three numbers by k, for example 6, 8, 10 from 3, 4, 5.
  • Mixing up which number is the hypotenuse: c is always the largest, and a and b are the legs, though a may be larger or smaller than b.

About this calculator

This calculator generates Pythagorean triples using Euclid's formula: for any two positive integers m > n, the triple a = m² − n², b = 2mn, c = m² + n² always satisfies a² + b² = c². Choosing m and n coprime and not both odd yields every primitive Pythagorean triple (other choices, such as m = 3, n = 1 giving 8-6-10, give a multiple of a primitive triple), and scaling the result by any integer k produces all non-primitive ones too.

Pythagorean triples describe right triangles with whole-number side lengths — like the well-known 3-4-5 triangle — and are used in geometry education, construction layout (squaring corners without a protractor), and number theory.

Was this helpful?

You can pick up to 3 reactions.

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators