Pythagorean Triple Calculator

Generate a Pythagorean triple from two integers and a scale factor, with a leg check, perimeter, area and primitive status.

Math and PercentUpdated 2026-11-184 min read
Pythagorean Triple Calculator
Must be greater than n.
Use 1 for a primitive triple, or a larger whole number to scale every side.
Triple (a, b, c)
...
Shorter leg...
Longer leg...
Hypotenuse...
Square check...
Perimeter...
Area...
Primitive status...

What it does

A Pythagorean triple is a set of three whole numbers that fit perfectly into the Pythagorean theorem. Put them in place of the two legs and the hypotenuse of a right triangle and the squares add up exactly: a squared plus b squared equals c squared. The pair 3, 4, 5 is the familiar example, and the next ones include 5, 12, 13 and 8, 15, 17.

The interest in these triples goes beyond school arithmetic. East Tennessee State University's number theory notes record that Babylonian tablets list large examples such as 319, 360, 481, long before a written proof existed. A triple gives an exact right angle using only integer lengths, which is why it keeps turning up in construction layouts and in the study of whole numbers.

Euclid's formula generates the whole family. Pick two positive integers m and n with m greater than n. One leg is m squared minus n squared, the other is 2 m n, and the hypotenuse is m squared plus n squared. Multiplying all three by a whole scale factor k stretches the triangle without breaking the right angle. Bridgewater State University's article on Pythagorean triples traces this rule to Book X of Euclid's Elements.

Some triples are primitive and some are not. A primitive triple has no common factor shared by all three sides. The rule from Cut-the-Knot and the university notes is the same: m and n must be coprime and of opposite parity, and the scale factor must be 1. If m and n are both odd, or share a factor, the result is still a valid triple but it is a scaled copy of a smaller one.

This page takes m, n and the scale factor, then returns the two legs, the hypotenuse, the square check, the perimeter, the area and whether the triple is primitive. It works in one direction only: to use it you supply the two generating integers. Finding m and n from a known side is a different question and is not covered here.

How to use

  1. Enter a whole number m that is at least 2.
  2. Enter a whole number n that is at least 1 and smaller than m.
  3. Leave the scale factor at 1 for a primitive candidate, or raise it to scale the sides.
  4. Read the two legs in ascending order and the hypotenuse last.
  5. Use the square check to confirm the two leg squares add to the hypotenuse square.
  6. Check the primitive status to see whether the triple can be divided down to a smaller one.

Formula

a = m squared - n squared, b = 2 m n, c = m squared + n squared, with m > n > 0. Multiply each side by a whole scale factor k. The triple is primitive when k = 1, gcd(m, n) = 1 and m and n have opposite parity.
m
Larger generating integer, at least 2.
n
Smaller generating integer, at least 1 and less than m.
k
Whole scale factor applied to all three sides.
a
First leg, m squared minus n squared, scaled by k.
b
Second leg, 2 m n, scaled by k.
c
Hypotenuse, m squared plus n squared, scaled by k.

Euclid's rule appears in Book X of the Elements and, as the university notes show, every primitive triple arises from exactly one suitable pair m and n. The two legs are displayed in ascending order, so the odd leg may come first or second depending on the pair. A scale factor greater than 1 always gives a non primitive triple, even when m and n themselves are coprime and of opposite parity.

Worked example

Example: the triple generated by m = 2 and n = 1

Defaults: m = 2, n = 1 and scale factor k = 1.

  1. First leg: m squared minus n squared = 4 - 1 = 3, then 3 x 1 = 3.
  2. Second leg: 2 m n = 2 x 2 x 1 = 4, then 4 x 1 = 4.
  3. Hypotenuse: m squared plus n squared = 4 + 1 = 5, then 5 x 1 = 5.
  4. Square check: 3 squared + 4 squared = 9 + 16 = 25, and 5 squared = 25.
  5. Perimeter: 3 + 4 + 5 = 12. Area: 3 x 4 / 2 = 6 square units.
  6. The pair 2 and 1 is coprime and has opposite parity, and k = 1, so the status is Primitive.
  7. The tool shows 3, 4, 5 with check 9 + 16 = 25, perimeter 12, area 6 and Primitive.

Reference table

Triples from Euclid's formula with scale factor 1 for small pairs m and n
mnTriple (a, b, c)Primitive?
213, 4, 5Yes
325, 12, 13Yes
418, 15, 17Yes
5220, 21, 29Yes
6327, 36, 45No

Limits

  • Accepts only positive whole numbers with m greater than n, so decimal inputs are rejected.
  • Generates triples from m, n and k; it cannot recover those integers from a single known side.
  • Triples whose hypotenuse would exceed 1,000,000,000,000,000 are rejected to keep the output readable.
  • A triple fixes only the side lengths, not where the triangle sits or which way it points.

Common mistakes

  • Setting m equal to n or smaller than n, which gives a zero or negative leg.
  • Assuming every pair m and n gives a primitive triple; both odd numbers or a shared factor change the status.
  • Forgetting the scale factor when stretching a known triple by a whole number.
  • Mistaking the longer leg for the hypotenuse; the hypotenuse is always m squared plus n squared.
  • Entering decimal values for m or n, since Euclid's parameterization needs integers.

Try it yourself

Quick checks. Answers sit tucked under each question.

Generate the triple for m = 5, n = 2 with scale 1.

First leg 25 - 4 = 21, second leg 2 x 5 x 2 = 20, hypotenuse 25 + 4 = 29, shown as 20, 21, 29. Check: 400 + 441 = 841 = 29 squared. Perimeter 70, area 210, primitive.

What triple comes from m = 2, n = 1 with scale factor 2?

Scaling 3, 4, 5 by 2 gives 6, 8, 10. Check: 36 + 64 = 100 = 10 squared. Perimeter 24, area 24, and the status is Not primitive.

Is the triple 9, 12, 15 primitive?

No. It is 3 times 3, 4, 5, from m = 2, n = 1 and scale 3. Check: 81 + 144 = 225 = 15 squared.

Questions

What is a Pythagorean triple?

Three positive whole numbers a, b and c that satisfy a squared plus b squared = c squared. They are exactly the integer side lengths of a right triangle.

What does Euclid's formula generate?

Given integers m > n > 0 it produces a = m squared minus n squared, b = 2 m n and c = m squared plus n squared, which always satisfy the Pythagorean equation.

What makes a triple primitive?

The three sides share no common factor. In the formula this happens when the scale factor is 1, m and n are coprime, and one of m and n is even while the other is odd.

Can I find a triple from one known side?

Not with this tool. It runs Euclid's formula forward, so you must enter the generating integers m and n. A known side leads to a separate search problem.

Why is the hypotenuse always m squared plus n squared?

Expanding (m squared minus n squared) squared plus (2 m n) squared gives m to the fourth plus 2 m squared n squared plus n to the fourth, which is exactly (m squared plus n squared) squared.

Are there infinitely many primitive triples?

Yes. Every coprime pair m and n of opposite parity with m greater than n gives a different primitive triple, and there is no end to such pairs.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.