Finding the Integer Solutions of a2+b2=c2

G.R.Dixon, 1/16/2006 (Revised 8/18/2008)

We begin by recasting the equation as

. (1)

In words, a2 equates to the area of a rectangle of sides (c-b) and (c+b). For all odd values of a>3 there is always at least one solution:

, (2a)

, (2b)

, (2c)

, (2d)

, (2e)

. (2f)

For example, assume that a=7. Then

, (3a)

, (3b)

, (3c)

, (3d)

, (3e)

. (3f)

In the case of a=4 (an even integer), the a2 X 1 rectangle strategy fails, for we end up with c=17/2, and c is non-integer. Furthermore, using an 8 X 2 rectangle produces the result that c=5. Assuming c must be >a+2, this rectangle also fails. And of course a 4 by 4 rectangle is disallowed. Thus a=4 has no solutions. Similarly for a=1 and a=2.

For even integers >5 there is always a solution, but a rectangle without unit-length sides must be invoked. For example, in the case of a=6,

, (4a)

, (4b)

. (4c)

The rectangle with unit-length sides does not work. However, a 2 x 18 rectangle does work:

, (5a)

, (5b)

, (5c)

, (5d)

. (5e)

Similarly for all even values of a>5.

In some cases there is more than one pair of values for c and b. For example, if a=9 then (since a2 is odd) we always have c+b=81, etc., producing c=41 and b=40. But we can also say that c+b=27, c-b=3, producing c=15 and b=12. The case a=9 therefore has two solutions.

Table 1 lists all triples (a,b,c) for a=1,2,…,100. Note the many multiple solutions. The simple program following the table produces the solutions.

Table 1

3,4,5

5,12,13

6,8,10

7,24,25

8,15,17

9,12,15

9,40,41

10,24,26

11,60,61

12,16,20

12,35,37

13,84,85

14,48,50

15,20,25

15,36,39

15,112,113

16,30,34

16,63,65

17,144,145

18,24,30

18,80,82

19,180,181

20,21,29

20,48,52

20,99,101

21,28,35

21,72,75

21,220,221

22,120,122

23,264,265

24,32,40

24,45,51

24,70,74

24,143,145

25,60,65

25,312,313

26,168,170

27,36,45

27,120,123

27,364,365

28,45,53

28,96,100

28,195,197

29,420,421

30,40,50

30,72,78

30,224,226

31,480,481

32,60,68

32,126,130

32,255,257

33,44,55

33,56,65

33,180,183

33,544,545

34,288,290

35,84,91

35,120,125

35,612,613

36,48,60

36,77,85

36,105,111

36,160,164

36,323,325

37,684,685

38,360,362

39,52,65

39,80,89

39,252,255

39,760,761

40,42,58

40,75,85

40,96,104

40,198,202

40,399,401

41,840,841

42,56,70

42,144,150

42,440,442

43,924,925

44,117,125

44,240,244

44,483,485

45,60,75

45,108,117

45,200,205

45,336,339

45,1012,1013

46,528,530

47,1104,1105

48,55,73

48,64,80

48,90,102

48,140,148

48,189,195

48,286,290

48,575,577

49,168,175

49,1200,1201

50,120,130

50,624,626

51,68,85

51,140,149

51,432,435

51,1300,1301

52,165,173

52,336,340

52,675,677

53,1404,1405

54,72,90

54,240,246

54,728,730

55,132,143

55,300,305

55,1512,1513

56,90,106

56,105,119

56,192,200

56,390,394

56,783,785

57,76,95

57,176,185

57,540,543

57,1624,1625

58,840,842

59,1740,1741

60,63,87

60,80,100

60,91,109

60,144,156

60,175,185

60,221,229

60,297,303

60,448,452

60,899,901

61,1860,1861

62,960,962

63,84,105

63,216,225

63,280,287

63,660,663

63,1984,1985

64,120,136

64,252,260

64,510,514

64,1023,1025

65,72,97

65,156,169

65,420,425

65,2112,2113

66,88,110

66,112,130

66,360,366

66,1088,1090

67,2244,2245

68,285,293

68,576,580

68,1155,1157

69,92,115

69,260,269

69,792,795

69,2380,2381

70,168,182

70,240,250

70,1224,1226

71,2520,2521

72,96,120

72,135,153

72,154,170

72,210,222

72,320,328

72,429,435

72,646,650

72,1295,1297

73,2664,2665

74,1368,1370

75,100,125

75,180,195

75,308,317

75,560,565

75,936,939

75,2812,2813

76,357,365

76,720,724

76,1443,1445

77,264,275

77,420,427

77,2964,2965

78,104,130

78,160,178

78,504,510

78,1520,1522

79,3120,3121

80,84,116

80,150,170

80,192,208

80,315,325

80,396,404

80,798,802

80,1599,1601

81,108,135

81,360,369

81,1092,1095

81,3280,3281

82,1680,1682

83,3444,3445

84,112,140

84,135,159

84,187,205

84,245,259

84,288,300

84,437,445

84,585,591

84,880,884

84,1763,1765

85,132,157

85,204,221

85,720,725

85,3612,3613

86,1848,1850

87,116,145

87,416,425

87,1260,1263

87,3784,3785

88,105,137

88,165,187

88,234,250

88,480,488

88,966,970

88,1935,1937

89,3960,3961

90,120,150

90,216,234

90,400,410

90,672,678

90,2024,2026

91,312,325

91,588,595

91,4140,4141

92,525,533

92,1056,1060

92,2115,2117

93,124,155

93,476,485

93,1440,1443

93,4324,4325

94,2208,2210

95,168,193

95,228,247

95,900,905

95,4512,4513

96,110,146

96,128,160

96,180,204

96,247,265

96,280,296

96,378,390

96,572,580

96,765,771

96,1150,1154

96,2303,2305

97,4704,4705

98,336,350

98,2400,2402

99,132,165

99,168,195

99,440,451

99,540,549

99,1632,1635

99,4900,4901

100,105,145

100,240,260

100,495,505

100,621,629

100,1248,1252

100,2499,2501

Program that Produces Solutions

Option Explicit

Private Sub cmdFindSQR_Click()

Const Size As Long = 100# 'Number of a values computed

Const betascale As Double = 1000 'Max value for beta

Dim a As Long 'Integer value of a

Dim b, c As Double 'b and c (might evaluate to non-integers)

Dim index1 As Double

Dim index2 As Long

Dim beta As Double 'Trial b = a + beta

Open "c:\WINMCAD\Physics\Trips.PRN" For Output As #1

For index1 = 1 To Size

Debug.Print index1

a = index1

beta = 0

Do

beta = beta + 1

If beta > betascale * Size Then Exit Do

b = a + beta 'Only integer values of b considered

c = Sqr(a ^ 2 + b ^ 2)

If c / Int(c) = 1 Then 'Integer c test

Write #1, a, b, c 'Record integer a,b,c sets

End If

Loop

Next index1

MsgBox ("Done")

Close

Stop

End Sub