Ruby 2.4

Prime::Generator23

class Prime::Generator23

Parent:Prime::PseudoPrimeGenerator

Generates all integers which are greater than 2 and are not divisible by either 2 or 3.

This is a pseudo-prime generator, suitable on checking primality of an integer by brute force method.

Public Class Methods

new() Show source

Calls superclass method Prime::PseudoPrimeGenerator.new

# File lib/prime.rb, line 348 def initialize @prime = 1 @step = nil super end

Public Instance Methods

next()

Alias for: succ

rewind() Show source

# File lib/prime.rb, line 368 def rewind initialize end

succ() Show source

# File lib/prime.rb, line 354 def succ if (@step) @prime += @step @step = 6 - @step else case @prime when 1; @prime = 2 when 2; @prime = 3 when 3; @prime = 5; @step = 2 end end @prime end

Also aliased as: next

Ruby Core © 1993–2017 Yukihiro Matsumoto

Licensed under the Ruby License.

Ruby Standard Library © contributors

Licensed under their own licenses.