Some integers are one more than the sum of the squares of their digits in base 10.
Prove that the set of such integers is finite and list all of them.
Finiteness:
9^2 + 1 = 82
2(9^2) + 1 = 163
3(9^2) + 1 = 244
4(9^2) + 1 = 325
so no more than 3 digits is possible, as even if they're all 9's, the sum is only 3 digits until you get even more digits needed, and in fact, no higher than 244; in fact much less as it certainly can't start with 9, but we can check up to that value.
Evaluate the list:
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For n = 1 To 244
ns$ = LTrim(Str(n))
t = 0
For i = 1 To Len(ns)
t = t + Val(Mid(ns, i, 1)) * Val(Mid(ns, i, 1))
Next
If t + 1 = n Then
Text1.Text = Text1.Text & n & crlf
End If
Next n
Text1.Text = Text1.Text & crlf & " done"
End Sub
finds 35 and 75.
|
Posted by Charlie
on 2015-12-08 10:45:22 |