Pythagorean Triples

"Triple the Fun with Pythagoras!"

Stage No:

...loading...

This app explores the fascinating world of Pythagorean triples. A Pythagorean triple consists of three positive integers a, b, and c such that a² + b² = c². These triples can be generated using the formulas:

  • a = x² - y²
  • b = 2xy
  • c = x² + y²

Here, x and y are positive integers where x > y. Copilot suggested that it was Greek mathematician Euclid who first formalized this method for generating triples.

More background
Pythagorean Triples
A 'right' triangle

You likely remember the Pythagorean Theorem from high school Geometry: a² + b² = c². This theorem states that in a right triangle, the square of the length of the hypotenuse (c) is equal to the sum of the squares of the lengths of the other two sides (a and b). The most famous example is the 3-4-5 triangle, where a = 3, b = 4, and c = 5. The 3 and the 4 are the legs of the triangle, while the 5 is the hypotenuse.

Use this app to learn more about these triples and how they are generated!


We provided Copilot with a Python3 source code file and it used that code to generate this application. Note that the Python3 rendition came from an earlier Java app, which Copilot converted to Python3!

Compare this stage with Stage 1: several improvements were made.

Please enter a valid positive integer (≥ 1).