Skip to content

Instantly share code, notes, and snippets.

@lune-sta
Created August 17, 2012 21:03
Show Gist options
  • Save lune-sta/3382641 to your computer and use it in GitHub Desktop.
Save lune-sta/3382641 to your computer and use it in GitHub Desktop.
Project Euler 27
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