Here is a neat little formula for generating Pythagorean triples, which are positive integers which could form the side lengths of a right triangle.
For example, with m = 2 and n = 1, we get the familiar triangle with side lengths 3, 4, and 5. You can see that there is an infinite number of different Pythagorean triples, because the number of natural numbers is infinite.
Where a, b, and c have no common factors, the triple is called a fundamental Pythagorean triple or a primitive Pythagorean triple. It can be shown that, where m and n have no common factors and they are not both odd, the formula above generates a fundamental Pythagorean triple. This formula for generating Pythagorean triples was discovered by the Greek mathematician Diophantus around 250 A.D.
Here's a quick-and-dirty Java applet to quickly generate some Pythagorean triples. If you like Java applets, you may also want to check out my applet for Pascal's Art. Also visit cut-the-knot.org because they have some interesting ones.
View source code.
Here is a table of the first few numbers generated by this formula:
|m||n||Leg X ||Leg Y (2mn)||Hypotenuse ||Triangle Type|
See also Pythagoras.