Pythagorean Triples

Routine Summary

Displays the Pythagorean triples.


C - how many triples you want to display



Variables Used

A, B, C

Calculator Compatibility




URL: United TI


:Disp {A²-B²,2AB,A²+B²
:If getKey:Pause

A Pythagorean triple occurs when, while using the Pythagorean Theorem a2+b2=c2 to find the three sides of a right triangle, all three values are whole integers. For example, a common triple is 3,4,5 — in this case, 9 (32) + 16 (42) = 25 (52). The general formula that can be derived to figure out when a triple occurs is: a=(A2-B2) b=(2AB) c=(A2+B2).

Now that you know what a Pythagorean triple is, the routine should be pretty clear. We are essentially looping over the range of values that we want to find triples in, and then displaying the triples as a three element list using the above mentioned formula. Because there can be many triples found, and displaying all of them would just be like a blur on the screen, the Pause command allows you to temporarily halt the program so you can see the triples that are currently displayed.


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.