The number N is a sum of 4 different numbers, each being a square of one of the 4 smallest divisors of N (e.g. N=36 does not qualify since 1^2+2^2+3^2+4^2
sums up to 30, not 36.)
Provide a full list of
similar numbers or show that none exist.
DefDbl A-Z
Dim crlf$, dvr(4)
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr(13) + Chr(10)
For n = 4 To 10000
dct = 0
sr = Sqr(n)
For i = 1 To n
q = n / i
If q = Int(q) Then
dct = dct + 1
dvr(dct) = i
If dct = 4 Then Exit For
End If
If dct = 1 And i > sr Then Exit For
DoEvents
Next
If dct < 4 And dct > 1 Then
If dvr(dct) < n Then
dct = dct + 1: dvr(dct) = n / dvr(dct - 2)
If dvr(dct) < n And dct < 4 Then
dct = dct + 1: dvr(dct) = n / dvr(dct - 4)
End If
End If
End If
DoEvents
If dct = 4 Then
If dvr(1) * dvr(1) + dvr(2) * dvr(2) + dvr(3) * dvr(3) + dvr(4) * dvr(4) = n Then
Text1.Text = Text1.Text & n & " " & dvr(1) * dvr(1) & " " & dvr(2) * dvr(2) & " " & dvr(3) * dvr(3) & " " & dvr(4) * dvr(4)
Text1.Text = Text1.Text & crlf
End If
End If
Next
Text1.Text = Text1.Text & crlf & tot & " done"
End Sub
finds only
130 = 1 + 4 + 25 + 100
|
Posted by Charlie
on 2018-07-08 15:55:49 |