Created
August 17, 2012 21:03
-
-
Save lune-sta/3382641 to your computer and use it in GitHub Desktop.
Project Euler 27
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 | |
(-999..999).each do |a| | |
Prime.each(999).to_a.each do |b| | |
n = 0 | |
n += 1 while Prime.prime?(n ** 2 + a * n + b) | |
max, answer = n, a * b if max < n | |
end | |
end | |
puts answer # -59231 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment