Class: PrimalInstinct::Generator::LucasLehmer

Inherits:
Object
  • Object
show all
Defined in:
lib/primal_instinct/generator/lucas_lehmer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#lengthObject (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

#callObject



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