Pythagorean Triples +- HP Forums (http://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Pythagorean Triples (/thread-7746.html) |
Pythagorean Triples - Eddie W. Shore - 02-08-2017 11:42 PM Criteria The program PYTHA calculates a Pythagorean triple. A Pythagorean triple is a set of three positive integers A, B, and C that represent the lengths of a right triangle, with C being the hypotenuse. Hence, A^2 + B^2 = C^2. Pythagorean triples can be generated with three arbitrary positive integers M, N, and K with the following criteria: 1. M > N 2. M and N are coprime. That is, gcd(M, N) = 1 (gcd, greatest common denominator) A, B, and C are generated by: A = K * (M^2 – N^2) B = K * (2 * M * N) C = K * (M^2 + N^2) Code: EXPORT PYTHA(M,N,K) Source: “Pythagorean Triple” Wikipedia. Last Modified February 7, 2017. https://en.wikipedia.org/wiki/Pythagorean_triple Accessed February 7, 2017 |