Class
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.
Class Methods
::
lib/prime.rb
View on GitHub
# File tmp/rubies/ruby-2.7.6/lib/prime.rb, line 352
def initialize
@prime = 1
@step = nil
super
end
No documentation available
Instance Methods
#
lib/prime.rb
View on GitHub
# File tmp/rubies/ruby-2.7.6/lib/prime.rb, line 372
def rewind
initialize
end
No documentation available
#
lib/prime.rb
View on GitHub
# File tmp/rubies/ruby-2.7.6/lib/prime.rb, line 358
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
No documentation available