Difference between revisions of "TI-BASIC:Pythagorean Triples"
(Initial automated import) |
(Automated superscript correction) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Template:TI-BASIC:Routine | {{Template:TI-BASIC:Routine | ||
− | |picture= | + | |picture= |
|summary=Displays the Pythagorean triples. | |summary=Displays the Pythagorean triples. | ||
|input=''C'' - how many triples you want to display | |input=''C'' - how many triples you want to display | ||
Line 7: | Line 7: | ||
|compatibility=TI-83/84/+/SE | |compatibility=TI-83/84/+/SE | ||
|author=Weregoose | |author=Weregoose | ||
− | |authors= | + | |authors= |
|url=http://www.unitedti.org/index.php?showtopic=4350&view=findpost&p=68050 United TI | |url=http://www.unitedti.org/index.php?showtopic=4350&view=findpost&p=68050 United TI | ||
|download=[file pythagoreantriples.zip] | |download=[file pythagoreantriples.zip] | ||
Line 18: | Line 18: | ||
:End:End | :End:End | ||
− | A [wikipedia:Pythagorean_triple Pythagorean triple] occurs when, while using the [wikipedia:Pythagorean_theorem Pythagorean Theorem] a | + | A [wikipedia:Pythagorean_triple Pythagorean triple] occurs when, while using the [wikipedia:Pythagorean_theorem Pythagorean Theorem] a<sup>2</sup>+b<sup>2</sup>=c<sup>2</sup> 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 (3<sup>2</sup>) + 16 (4<sup>2</sup>) = 25 (5<sup>2</sup>). The general formula that can be derived to figure out when a triple occurs is: a=(A<sup>2</sup>-B<sup>2</sup>) b=(2AB) c=(A<sup>2</sup>+B<sup>2</sup>). |
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 [[TI-BASIC:Lists|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 [[TI-BASIC:Pause|Pause]] command allows you to temporarily halt the program so you can see the triples that are currently displayed.[[Category:TI-BASIC]] | 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 [[TI-BASIC:Lists|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 [[TI-BASIC:Pause|Pause]] command allows you to temporarily halt the program so you can see the triples that are currently displayed.[[Category:TI-BASIC]] | ||
[[Category:TIBD]] | [[Category:TIBD]] |
Latest revision as of 22:22, 24 February 2016
Routine Summary
Displays the Pythagorean triples.
Inputs
C - how many triples you want to display
Outputs
None
Variables Used
A, B, C
Calculator Compatibility
TI-83/84/+/SE Author
WeregooseURL: United TI Download
:For(A,2,C :For(B,1,A-1 :Disp {A²-B²,2AB,A²+B² :If getKey:Pause :End:End
A [wikipedia:Pythagorean_triple Pythagorean triple] occurs when, while using the [wikipedia:Pythagorean_theorem 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.