106 - Fermat vs. Pythagoras

This problem asks you to generate all primitive Pythagorean triples less than an upper bound.

I use Euclid’s formula to generate all primitive Pythagorean triples. To do so, I generate all coprime pairs $(m, n)$ with one of them is an even number. If you use Euclid’s formula, remember that you also need a boundary condition of $(m, n)$ — I mean when to stop generating them. Here is a reference solution.

Creative Commons License
This blog by Che-Liang Chiou is licensed under a Creative Commons Attribution 4.0 International License.