Skip to content

Instantly share code, notes, and snippets.

@forresty
Created April 24, 2010 10:07
Show Gist options
  • Save forresty/377571 to your computer and use it in GitHub Desktop.
Save forresty/377571 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
last = 1
def num1(num)
result = 0
while num > 0
if num % 10 == 1
result += 1
end
num = num / 10
end
result
end
2.upto(10000000) do |i|
fn = last + num1(i)
if fn == i
puts fn
break
end
last = fn
puts i if i % 1000 == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment