Last active
April 14, 2017 12:05
-
-
Save dhiachou/98e9e29816cdc913a1a01e261b1b66ed to your computer and use it in GitHub Desktop.
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 'prime' | |
class Integer | |
# Monkey patch to check if n is palindromic | |
def is_palindrome? | |
self.to_s == self.to_s.reverse | |
end | |
end | |
# Prints the first n palindromic prime int | |
n = STDIN.gets.chomp.to_i | |
puts "#{Prime.lazy.select{|e| e.is_palindrome?}.first(n)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment