Skip to content

Instantly share code, notes, and snippets.

@lune-sta
Created August 16, 2012 21:13
Show Gist options
  • Save lune-sta/3373708 to your computer and use it in GitHub Desktop.
Save lune-sta/3373708 to your computer and use it in GitHub Desktop.
Project Euler 26
require 'Prime'
max, answer = 0, 0
Prime.each(1000).to_a.reject{|p| p == 2 || p == 5}.each do |p|
a, c = 10, 1
while a % p != 1 do
c += 1
a *= 10
end
max, answer = c, p if max < c
end
puts answer # 983
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment