(15C) Pythagorean Triples
|
03-23-2017, 03:34 AM
Post: #1
|
|||
|
|||
(15C) Pythagorean Triples
This program calculates the Pythagorean triple (A, B, C) such that A^2 + B^2 = C^2 by the formulas:
A = K * (M^2 – N^2) B = K * (2 * M * N) C = K * (M^2 + N^2) The conditions are M, N, and K are all positive integers where M > N. Store M into memory 0, N into memory 1, and K into memory 2. A, B, and C are stored in memories 3, 4, and 5, respectively. If no such combination can be found, a single zero (0) is returned. Code:
Example: Input: R0 = M = 4, R1 = N = 1, R2 = 2. Output: 30, 16, 34 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(15C) Pythagorean Triples - Eddie W. Shore - 03-23-2017 03:34 AM
|
User(s) browsing this thread: 1 Guest(s)