0

This is the problem I need to solve. It comes directly out of a C++ Programming book:

A right triangle can have sides that are all integers. A set of three integer values for the sides of a right triangle is called a Pythagorean triple. These three sides must satisfy the relationship that the sume of the squares of two of the sides equal to the square of the hypotenuse. Find all Pythagorean triples for Side1, side2, and hypotenuse all no larger than 500. Use a triple nested loop that tries all possibilities.

Any help would be much appreciated.... I am fully halted on this problem.

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
0

This is the problem I need to solve. It comes directly out of a C++ Programming book:

Any help would be much appreciated.... I am fully halted on this problem.

Never mind I completely had an epiphany and got it done.

0

Start by understanding the mathametics of the triangle -- see this wiki article. That article gives you the solution for the 16 primitive Pythagorean triples with c ≤ 100. That should give you the data you need to verify the accuracy of your program.

One way to do it would be the long way, create two loops that count from 1 to 500. Inside the inner-most loop calculate the equation c^2 = a^2 + b^2. (where ^ means squared).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.