G
Guest
I have to write a program to find all Pythagorean triples for a right
triangle. I know that the squares of two sides of the triangle must equal
the square of the third (longest) side. However, I am not sure how to use a
triple-nested for...next loop to try all possibilities.
For instance, take a look at these numbers:
a 3 5 7 8 9 11
b 4 12 24 15 40 60
c 5 13 25 17 41 61
Notice that in each case "a" squared plus "b" squared is equal to the sum of
c squared. My program has to compute such a table by iterating through
several combinations of numbers to locate ones that meet this criteria.
Any suggestions would be helpful.
triangle. I know that the squares of two sides of the triangle must equal
the square of the third (longest) side. However, I am not sure how to use a
triple-nested for...next loop to try all possibilities.
For instance, take a look at these numbers:
a 3 5 7 8 9 11
b 4 12 24 15 40 60
c 5 13 25 17 41 61
Notice that in each case "a" squared plus "b" squared is equal to the sum of
c squared. My program has to compute such a table by iterating through
several combinations of numbers to locate ones that meet this criteria.
Any suggestions would be helpful.