Advertisement

Pythagorean triples calculator

Check a triple in any side order, or generate one from positive integers m > n. The result also identifies whether the triple is primitive.

Calculator

Pythagorean triple?
Yes
Integer a
3
Integer b
4
Integer c
5
Primitive?
Yes

Advertisement

How this calculator works

A Pythagorean triple consists of positive integers satisfying the right triangle equation. Checking uses exact integer arithmetic, so a large square is not rounded. Generation uses Euclid parameters and permits any positive scale k. The generated legs may appear in either order. A primitive triple has no common integer factor greater than one.

Formula

Check: a²+b²=c² with c the largest. Generate: a=k(m²-n²), b=2kmn, c=k(m²+n²), where m>n>0.

Worked example

m = 2, n = 1 and k = 1 give 3, 4 and 5. With m = 3 and n = 2 the triple is 5, 12 and 13. Scaling the first triple by 2 gives 6, 8 and 10, which is not primitive.

Advertisement

Frequently asked questions

Must m and n be coprime?

No, but primitive output requires coprime m and n of opposite parity and k = 1. Other choices still give valid triples.

Why are decimals rejected?

A Pythagorean triple is an integer concept. Use the right triangle calculator for arbitrary positive side lengths.

What is the input limit?

Each input is limited to a positive safe JavaScript integer. Generated integers are calculated and displayed exactly as text, even if larger than that limit.

Sources

Advertisement