Skip to content

Instantly share code, notes, and snippets.

@pheuter
Created October 8, 2010 22:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pheuter/617678 to your computer and use it in GitHub Desktop.
Save pheuter/617678 to your computer and use it in GitHub Desktop.
require "prime"
fib = Fiber.new do
x, y = 0, 1
loop do
Fiber.yield y
x,y = y, x+y
end
end
min = gets.chomp.to_i
loop do
tmp = fib.resume
if tmp > min and tmp.prime?
sum = 0
(tmp+1).prime_division.each { |divs| sum += divs.first }
puts sum
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment