(42S) List Pythagorean Triples
|
10-16-2019, 07:33 PM
(This post was last modified: 10-17-2019 03:13 PM by ijabbott.)
Post: #1
|
|||
|
|||
(42S) List Pythagorean Triples
This program lists Pythagorean triples, (natural numbers \(a, b, c\), such that \(a^2 + b^2 = c^2\)) as alpha strings on the display, starting with "3,4,5". They are not listed in any monotonic order, but successive hypotenuses are listed in a reverse sawtooth pattern.
The triples (\(a,b,c\)) are generated from pairs of natural numbers \(m\), \(n\), such that \(m > n > 0\), and \(m\) and \(n\) are co-prime and not both odd (to filter out non-primitive triples such as 6,8,10), using Euclid's formula: \[a = m^2 - n^2, b = 2mn, c = m^2 + n^2\] The program uses registers R00 and R01 to store \(m\) and \(n\), and uses the ALPHA register to show the triple "\(a,b,c\)" (if \(a < b\)), or "\(b,a,c\)" (if \(a > b\)). The program stops after each triple is displayed. Press R/S to continue. Code: 00 { 90-Byte Prgm } — Ian Abbott |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)