Each of A, B, C and D is a nonzero integer such that:
A
2 + B
2 + C
2 = D
4, and:
A + B + C = D
2
Find the four smallest values of abs(A) + abs(B) + abs(C)
Note: abs(x) is the
Absolute Value Function
The lowest four found were 15, 60, 77 and 79:
a b c d sum of abs values
-3 6 6 3 15
-12 24 24 6 60
-14 21 42 7 77
-15 24 40 7 79
-27 54 54 9 135
-48 96 96 12 240
-39 52 156 13 247
-56 105 120 13 281
-56 84 168 14 308
-60 96 160 14 316
-75 150 150 15 375
-80 105 336 19 521
-108 216 216 18 540
-66 78 429 21 573
-114 190 285 19 589
-84 105 420 21 609
-126 189 378 21 693
-135 216 360 21 711
-147 294 294 21 735
-192 384 384 24 960
-156 208 624 26 988
-224 420 480 26 1124
-243 486 486 27 1215
-224 336 672 28 1232
-240 384 640 28 1264
-155 186 930 31 1271
-264 385 840 31 1489
-300 600 600 30 1500
-66 69 1518 39 1653
-363 726 726 33 1815
-231 280 1320 37 1831
-350 525 1050 35 1925
-375 600 1000 35 1975
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For tot = 3 To 2000
For a0 = 1 To tot / 3
a2 = a0 * a0
For a = -a0 To a0 Step 2 * a0
For b0 = a0 To (tot - a0) / 2
b2 = b0 * b0
For b = -b0 To b0 Step 2 * b0
c0 = tot - a0 - b0
c2 = c0 * c0
For c = -c0 To c0 Step 2 * c0
d4 = a2 + b2 + c2
d2 = Sqr(d4)
rt4 = Int(Sqr(d2) + 0.5)
If rt4 * rt4 * rt4 * rt4 = d4 Then
d2 = Int(d2 + 0.5)
If a + b + c = d2 Then
Text1.Text = Text1.Text & mform(a, "###0") & " "
Text1.Text = Text1.Text & mform(b, "###0") & " "
Text1.Text = Text1.Text & mform(c, "###0") & " "
Text1.Text = Text1.Text & mform(Sqr(d2), "###0") & " "
Text1.Text = Text1.Text & " " & mform(a0 + b0 + c0, "###0") & crlf
DoEvents
End If
End If
Next
Next
Next
Next
Next
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function mform$(x, t$)
a$ = Format$(x, t$)
If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
mform$ = a$
End Function
|
Posted by Charlie
on 2015-09-06 14:13:34 |