Skip to content

Instantly share code, notes, and snippets.

@bragboy
Created November 12, 2015 10:53
Show Gist options
  • Select an option

  • Save bragboy/af0903b20eda4c655128 to your computer and use it in GitHub Desktop.

Select an option

Save bragboy/af0903b20eda4c655128 to your computer and use it in GitHub Desktop.
def is_lynchrel(n)
50.times do
n += n.to_s.reverse.to_i
return false if n.to_s == n.to_s.reverse
end
true
end
count = 0
1.upto(9999) do |n|
count +=1 if is_lynchrel(n)
end
puts "Lynchrel numbers below 10000 is #{count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment