S(x) denotes the sum of squares of the digits. For example:
S(97) = 92 + 72 = 130.
Find all possible positive integer values of N < 2014 such that:
N oF= (S(N) - 5) oC
N.B.: F = (9/5)*C + 32
*** As an extra challenge, solve this puzzle using a non computer program assisted method.
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
For n = 1 To 2014
rhs = (sosqd(n) - 5) * 9 / 5 + 32
If rhs = n Then
Text1.Text = Text1.Text & n & Str(sosqd(n)) & Str(rhs) & crlf
End If
Next
Text1.Text = Text1.Text & "done"
End Sub
Function sosqd(n)
s$ = LTrim(Str(n))
tot = 0
For i = 1 To Len(s$)
tot = tot + Val(Mid(s$, i, 1)) * Val(Mid(s$, i, 1))
Next
sosqd = tot
End Function
finds
185 90 185
N is 185, which is 85°C, having subtracted 5 from the sum of the squares of the digits, which is 90.
That's the only solution.
|
Posted by Charlie
on 2015-01-13 14:38:01 |