Class: PrimalInstinct::Generator::LucasLehmer
- Inherits:
-
Object
- Object
- PrimalInstinct::Generator::LucasLehmer
- Defined in:
- lib/primal_instinct/generator/lucas_lehmer.rb
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(length) ⇒ LucasLehmer
constructor
A new instance of LucasLehmer.
Constructor Details
#initialize(length) ⇒ LucasLehmer
Returns a new instance of LucasLehmer.
6 7 8 |
# File 'lib/primal_instinct/generator/lucas_lehmer.rb', line 6 def initialize(length) @length = length end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
4 5 6 |
# File 'lib/primal_instinct/generator/lucas_lehmer.rb', line 4 def length @length end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/primal_instinct/generator/lucas_lehmer.rb', line 10 def call ary = [] number = 1 until ary.length == length number += 1 ary << number if is_prime(number) end ary end |