Header tag

Friday, 21 February 2025

Calculator Games: Pythagorean Triples

 Pythagorean Triples


The Calculator Fun and Games book probably didn’t cover Pythagorean Triples because back in the mid 80s, pocket calculators didn’t have an x2 button.  Also, I didn’t start studying trigonometry and geometry until the late 80s, five or so years after I had the book, so the lack of an x2 button on my calculator didn’t even bother me.  The square root button was exciting enough, although it was a little boring because if you hammered it enough it always led to an answer of 1.

However, the concept still holds and it’s possible to study Pythagorean Triples with a basic calculator and a notepad and pen (although a scientific calculator will be helpful).

Pythagoras once decreed that for a right-angled triangle, a2 + b2 = h2.  The square of the hypotenuse, h, is equal to the sum of the squares of the other two sides.  The hypotenuse is the side of the triangle which is opposite the right angle.



Furthermore, we can find an easy solution to a2 + b2 = h2 since 32 + 42 = 52 (9 + 16 = 25).  Integer values of a, b and h (sometimes called c) are called Pythagorean triples.

The challenge is:  can you find any more?

Since Pythagoras did his maths thousands of years ago, many people have studied his work and found plenty more triples.  To list a few:

(3, 4, 5)

32+42=9+16=25=52

(5, 12, 13)

52+122=25+144=169=132

(7, 24, 25)

72+242=49+576=625=252

(8, 15, 17)

82+152 = 64+225 = 289 =172

(9, 12, 15)

92+122=81+144=225=152

Others include (20, 21, 29) and (12, 35, 37). 



GENERATING PYTHAGOREAN TRIPLES

It’s possible to generate a set of triples using the formulae:

a = m2−n2

b = 2mn

c = m2+n2

where m and n are positive integers.  For example, m = 4 and n = 2 gives:

a = 12
b = 16
c = 20

Which is a scaled-up version of the 3,4,5 triple (each number is 4* larger than the 3,4,5 triple).  This isn’t a unique triple, it’s just one that’s four times larger than an existing one.

Some observations:

It is not possible to have a Pythagorean triple that contains all prime numbers.  At least one of the numbers must be even (b = 2mn).  m = 2 and n=1 yields 3,4,5.

There are an infinite number of Pythagorean triples (since m and n can have any values).  Many of these are duplicates of other triples, just scaled up (for example, 12,16,20 is a scaled up version of 3,4,5).  

So I’m going to search for ‘unique’ triples that aren’t just multiples of smaller ones, and for this, I suspect that m and n must not have common factors.  For example, m = 4 and n = 2 can be simplified to m = 2 and n = 1 (divide by two), which is how (12,16,20) is related to (3,4,5).  (Wider reading on Pythagorean triples led me to discover that the accepted term is not ‘unique’ but ‘primitive’ triples.  You get the idea.  I have reworded the rest of my article to call them primitive, in line with the rest of the mathematical world).

m = 5, n = 1 gives (10,24,26) or (5,12,13) – which brings me to another observation:  Primitive Pythagorean triples generally contain at least one prime number.  In my list above, I gave (9,12,15) as an example, but that’s just another version of (3,4,5), in this case, scaled up by 3.  By definition,(and I know I haven’t defined them very well) primitive triples must contain three numbers that have no common factors that would enable them to be simplified.  Prime numbers guarantee this, but are not essential – for example, (16, 63, 65) is a triple with no primes.

An easy way to generate primitive triples is to use the m, n method, setting m to an even number and n to 1.  This means that a = m2−n2, and c = m2+n2 will only have a difference of two.

m

n

a

b

c

a2 + b2

c2

2

1

3

4

5

25

25

4

1

15

8

17

289

289

6

1

35

12

37

1369

1369

8

1

63

16

65

4225

4225

10

1

99

20

101

10201

10201

12

1

143

24

145

21025

21025

14

1

195

28

197

38809

38809

16

1

255

32

257

66049

66049

18

1

323

36

325

105625

105625

20

1

399

40

401

160801

160801

22

1

483

44

485

235225

235225

24

1

575

48

577

332929

332929

26

1

675

52

677

458329

458329

28

1

783

56

785

616225

616225

30

1

899

60

901

811801

811801

Prime numbers highlighted in bold.  Rows of green triples contain no prime numbers.

So: to continue our investigation: what happens if we set n = 2?  Do we still get an abundance of primitive triples?  We do, but only when m is odd.  When m is even and n=2, the values of a,b,c are all divisible by 4 (not shown below).  When m is divisible by 4, then a,b,c are all divisible by 8.

Here are the results for n=2 and m is odd: a series of primitive triples, some containing primes.

m

n

a

b

c

a2 + b2

c2

3

2

5

12

13

169

169

5

2

21

20

29

841

841

7

2

45

28

53

2809

2809

9

2

77

36

85

7225

7225

11

2

117

44

125

15625

15625

13

2

165

52

173

29929

29929

15

2

221

60

229

52441

52441

17

2

285

68

293

85849

85849

19

2

357

76

365

133225

133225

21

2

437

84

445

198025

198025

23

2

525

92

533

284089

284089

Prime numbers highlighted in bold.  Rows of green triples contain no prime numbers.

When n=3, we can generate primitive triples when m is an even number that is not divisible by 3 (m = 4, 8, 10, 14, 16, 20…).  When m and n are both odd, then a,b,c are divisible by 2 (unless m is divisible by 3, when a,b,c are all divisible by 9).  This leads to a complicated repeating pattern, which is easier to show than explain: 

m

n

a

b

c

Notes

4

3

7

24

25

Primitive

5

3

16

30

34

m,n both odd, a,b,c divisible by 2

6

3

27

36

45

 multiples of 3, all divisible by 9

7

3

40

42

58

m,n both odd, a,b,c divisible by 2

8

3

55

48

73

Primitive

9

3

72

54

90

m,n, odd and divisible by 3, a,b,c divisible by 18

10

3

91

60

109

Primitive

11

3

112

66

130

m,n both odd, a,b,c divisible by 2

12

3

135

72

153

 multiples of 3, all divisible by 9

13

3

160

78

178

m,n both odd, a,b,c divisible by 2

14

3

187

84

205

Primitive

15

3

216

90

234

m,n, odd and divisible by 3, a,b,c divisible by 18

16

3

247

96

265

Primitive

17

3

280

102

298

m,n both odd, a,b,c divisible by 2

18

3

315

108

333

 multiples of 3, all divisible by 9

19

3

352

114

370

m,n both odd, a,b,c divisible by 2

20

3

391

120

409

Primitive

21

3

432

126

450

m,n, odd and divisible by 3, a,b,c divisible by 18

22

3

475

132

493

Primitive

23

3

520

138

538

m,n both odd, a,b,c divisible by 2

24

3

567

144

585

 multiples of 3, all divisible by 9

25

3

616

150

634

m,n both odd, a,b,c divisible by 2

26

3

667

156

685

Primitive


The investigation (and the pattern-finding) continues, as we try n=4.  Here’s the result – it’s possible to find primitive Pythagorean triples for every case where m = odd again. 

m

n

a

b

c

Notes

5

4

9

40

41

Primitive

6

4

20

48

52

m,n both even: a,b,c divisible by 4

7

4

33

56

65

Primitive

8

4

48

64

80

m,n both divisible by 4, a,b,c divisible by 16

9

4

65

72

97

Primitive

10

4

84

80

116

m,n both even: a,b,c divisible by 4

11

4

105

88

137

Primitive

12

4

128

96

160

m,n both divisible by 4, a,b,c divisible by 32

13

4

153

104

185

Primitive

14

4

180

112

212

m,n both even: a,b,c divisible by 4

15

4

209

120

241

Primitive

16

4

240

128

272

m,n both divisible by 4, a,b,c divisible by 16

17

4

273

136

305

Primitive

18

4

308

144

340

m,n both even: a,b,c divisible by 4

19

4

345

152

377

Primitive

20

4

384

160

416

m,n both divisible by 4, a,b,c divisible by 32


We find that m and n must have no common factors in order to generate primitive triples.  This means m and n must be ‘relatively prime’ (an expression I learned during my wider reading into this project).  

This is starting to go beyond the scope of a calculator, and into spreadsheet territory, but it's still fascinating, and can still be done with a simple pocket calculator (or an app on your phone, naturally), even without an x2 button.

Summary:

It is not possible to have a Pythagorean triple that contains all prime numbers

It is possible to have a primitive Pythagorean triple that contains no prime numbers; a, b and c will be relatively prime, and these are generally generated by m and n being relatively prime too.

There are an infinite number of triples, and an infinite number of primitive triples


Previous Calculator Fun and Games articles:

No comments:

Post a Comment