Created
August 16, 2012 21:13
-
-
Save lune-sta/3373708 to your computer and use it in GitHub Desktop.
Project Euler 26
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' | |
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