A brief note on Pythagorean Triples

And I decided today to share what I learned about an algorithm for generating Pythagorean triples for any m and n, where  m, n \in Z.

A Pythagorean triple are any three whole numbers which satisfy the equation a^2 + b^2 = c^2. For any two integers  m and  n, let a = m^2 - n^2; b = 2 m n; and c = m^2 - n^2, and you will obtain a solution to the relation a^2 + b^2 = c^2.

It is therefore not that hard, if we allow m and n to be any numbers from 1 to any upper limit you like, to write a computer program to generate the first  x Pythagorean triples, allowing for negative values for a or b.

Published by Pi

I am Paul King, a math and science teacher. I help maintain the MIT FAQ Archive along with Nick Bolach. I am also the maintainer of a FAQ the archive.