class Prime::EratosthenesGenerator
- Parent:
- Prime::PseudoPrimeGenerator
An implementation of PseudoPrimeGenerator
.
Uses EratosthenesSieve
.
# File lib/prime.rb, line 411
def initialize
@last_prime_index = -1
super
end
# File lib/prime.rb, line 420
def rewind
initialize
end
# File lib/prime.rb, line 416
def succ
@last_prime_index += 1
EratosthenesSieve.instance.get_nth_prime(@last_prime_index)
end
Ruby Core © 1993–2020 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.