a. How many 5-digit numbers exist where one of its digits equals the sum of all other digits?
b. What is the sum of all those numbers?
No leading zeroes.
For n = 10000 To 99999
s$ = LTrim(Str(n))
largest = 0: total = 0
For i = 1 To 5
v = Val(Mid(s, i, 1))
total = total + v
If v > largest Then largest = v
If largest = total - largest Then
ct = ct + 1
tot = tot + n
Text1.Text = Text1.Text & n & crlf
Text1.Text = Text1.Text & crlf & ct & Str(tot) & " done"
2658 such numbers adding up to 109249191.
Posted by Charlie
on 2018-08-23 10:00:05