Class: Prime::TrialDivisionGenerator
- Inherits:
-
PseudoPrimeGenerator
- Object
- PseudoPrimeGenerator
- Prime::TrialDivisionGenerator
- Defined in:
- lib/prime.rb
Overview
An implementation of PseudoPrimeGenerator
which uses a prime table generated by trial division.
Instance Method Summary collapse
-
#initialize ⇒ TrialDivisionGenerator
constructor
A new instance of TrialDivisionGenerator.
- #rewind ⇒ Object
- #succ ⇒ Object (also: #next)
Methods inherited from PseudoPrimeGenerator
#each, #size, #upper_bound, #upper_bound=, #with_index, #with_object
Constructor Details
#initialize ⇒ TrialDivisionGenerator
Returns a new instance of TrialDivisionGenerator.
327 328 329 330 |
# File 'lib/prime.rb', line 327 def initialize @index = -1 super end |
Instance Method Details
#rewind ⇒ Object
335 336 337 |
# File 'lib/prime.rb', line 335 def rewind initialize end |
#succ ⇒ Object Also known as: next
332 333 334 |
# File 'lib/prime.rb', line 332 def succ TrialDivision.instance[@index += 1] end |