Skip to content

Instantly share code, notes, and snippets.

@pcasaretto
Created April 13, 2012 18:01
Show Gist options
  • Save pcasaretto/2378831 to your computer and use it in GitHub Desktop.
Save pcasaretto/2378831 to your computer and use it in GitHub Desktop.
1177711
require 'bigdecimal'
require 'bigdecimal/math'
include BigMath
buffer = ''
class String
def palindrome?
self == self.reverse
end
end
require 'mathn'
PI(100_000).to_s.each_char do |char|
buffer << char
if buffer.size == 7
if buffer.palindrome?
p "found palindrome #{buffer}"
if buffer.to_i.prime?
p "found answer #{buffer}"
break
end
end
buffer = ''
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment