首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Prime::EratosthenesGenerator

Parent:Prime::PseudoPrimeGenerator

An implementation of PseudoPrimeGenerator.

Uses EratosthenesSieve.

Public Class Methods

new() Show source

Calls superclass method Prime::PseudoPrimeGenerator.new

代码语言:javascript
复制
# File lib/prime.rb, line 309
def initialize
  @last_prime_index = -1
  super
end

Public Instance Methods

next()

Alias for: succ

rewind() Show source

代码语言:javascript
复制
# File lib/prime.rb, line 318
def rewind
  initialize
end

succ() Show source

代码语言:javascript
复制
# File lib/prime.rb, line 314
def succ
  @last_prime_index += 1
  EratosthenesSieve.instance.get_nth_prime(@last_prime_index)
end

Also aliased as: next

代码语言:txt
复制
 Ruby Core ? 1993–2017 Yukihiro Matsumoto

Licensed under the Ruby License.

Ruby Standard Library ? contributors

Licensed under their own licenses.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com