Free Hosting : Election 2008 : Drug Rehab : Troubled Teens : Teen Drug Treatment

Generating Pythagorean Triples

Here is a neat little formula for generating Pythagorean triples, which are positive integers which could form a right triangle.

  • Take any two positive integers. Call the larger m and the smaller n.
  • The legs of the right triangle are given by m² - n² and 2mn, and the hypotenuse is m² + n².

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.

Here's a quick-and-dirty Java applet to calculate some values quickly. If you're a big fan of Java applets, you may also want to check out my applet for Pascal's Art. Also visit cut-the-knot.com because they have some interesting ones.

View Source Code.

Here is a table of the first few numbers generated by this formula:
a b Leg X (a2 - b2) Leg Y (2ab) Hypotenuse (a2 + b2) Triangle Type
Primitive Composite
21345P1
3186102P1
4115817P2
512410262P4
61351237P3
714814502P7
3251213P4
421216204P1
52212029P5
623224408P1
72452853P6
4372425P7
531630342P2
632736459P1
734042582P5
5494041P8
642048524P4

See also Pythagoras.


Last updated November 26, 2001. URL: http://www.stormloader.com/ajy/pythtriples.html For questions or comments email James Yolkowski. Math Lair home page