Find all 3digit integers n (no leading zeroes) such that the sum of the
squares of the digits of n is exactly onehalf of n.
For n = 100 To 999
sumsq = 0
ns$ = LTrim(Str(n))
For i = 1 To Len(ns)
sumsq = sumsq + Val(Mid(ns, i, 1)) * Val(Mid(ns, i, 1))
Next
If 2 * sumsq = n Then Text1.Text = Text1.Text & n & crlf
DoEvents
Next
finds
298 is the only such number in the range of 3digit numbers.
4+81+64 = 149 = 298/2
Outside the range, only 50 fits the bill.

Posted by Charlie
on 20190605 12:29:13 