-
-
Save anonymous/7e8669de9b03369d743cb52e23dbeff9 to your computer and use it in GitHub Desktop.
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
def gap(g, inf, sup, gen = nil) | |
gen = prime_range(inf, sup) if gen.nil? | |
recent = gen.next | |
current = gen.next | |
return [recent, current] if current - recent == g | |
gap(g, inf, sup, gen) | |
end | |
def prime_range(inf, sup) | |
Enumerator.new do |enum| | |
while inf < sup | |
enum.yield inf if Prime.prime? inf | |
inf += 1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment