How many integers 0 < n < 10E18 have the property that the sum of the digits of n equals the sum of digits of 137n?
- by Allen
I'm stumped on a project Euler question, #290. Can anybody point me in the right direction?
i = 0
o = 0
p = 1
while i < 10 ** 18
j = i.to_s.split('').map(&:to_i)
k = j.inject(:+)
l = 137 * i
m = l.to_s.split('').map(&:to_i)
n = m.inject(:+)
if k == n
o += 1
end
if i == (9 * 10 ** p) * (10 ** p)
i += 18
p += 1
o += 1
else
i += 9
end
end
puts o