Created
April 13, 2012 18:01
-
-
Save pcasaretto/2378831 to your computer and use it in GitHub Desktop.
1177711
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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