Class: Prime::TrialDivisionGenerator

Inherits:
PseudoPrimeGenerator show all
Defined in:
lib/prime.rb

Overview

An implementation of PseudoPrimeGenerator which uses a prime table generated by trial division.

Instance Method Summary collapse

Methods inherited from PseudoPrimeGenerator

#each, #size, #upper_bound, #upper_bound=, #with_index, #with_object

Constructor Details

#initializeTrialDivisionGenerator

Returns a new instance of TrialDivisionGenerator.



429
430
431
432
# File 'lib/prime.rb', line 429

def initialize
  @index = -1
  super
end

Instance Method Details

#rewindObject



437
438
439
# File 'lib/prime.rb', line 437

def rewind
  initialize
end

#succObject Also known as: next



434
435
436
# File 'lib/prime.rb', line 434

def succ
  TrialDivision.instance[@index += 1]
end