Skip to content

Instantly share code, notes, and snippets.

@myokoym
Created August 16, 2012 13:22
Show Gist options
  • Save myokoym/3370054 to your computer and use it in GitHub Desktop.
Save myokoym/3370054 to your computer and use it in GitHub Desktop.
Problem035
#! ruby
require "prime"
ans = []
1.upto(999999) do |n|
a = n.to_s.split(//)
flag = true
a.size.times do |i|
b = a.dup
i.times do
t = b.shift
b << t
end
flag = false unless Prime.prime?(b.join.to_i)
end
p ans << a.join.to_i if flag
end
p ans
p ans.size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment