The Pythagorean theorem states that the sum of the squares of the sides of a right triangle is equal to the square of the hypotenuse. For example, if two sides of a right triangle have lengths of 3 and 4, then the hypotenuse must have a length of 5. Together the integers 3, 4, and 5 form a Pythagorean triple. There are an infinite number of such triples. Given two positive integers, m and n, where m> n, a Pythagorean triple can be generated by the following formulas:
side1 = m2 – n2
side2 = 2mn
hypotenuse = m2 + n2
The triple (side1 = 3, side2 = 4, hypotenuse = 5) is generated by this formula when m = 2 and n = 1. Write a program that takes values for m and n as input and displays the values of the Pythagorean triple generated by the formulas above.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.