chapter 7

12 Pages

## Pythagorean Triples

A Pythagorean triple is a list of three integers (a,b,c) such that a2+b2 = c2. Such a triple is called primitive if the integers are nonnegative and gcd(a,b,c) = 1. For example, (3,4,5) is a Pythagorean triple because 32+42 = 52. Although (30,40,50) and (−3,4,−5) are also Pythagorean triples, they are not primitive. In this chapter and the next we develop the C++ machinery necessary to find all

primitive Pythagorean triples with a,b,c≤ 1000 (or any other given value).