lib/primetable.rb
# One way or another, we need to get an array of consecutive prime numbers.
One way or another, we need to get an array of consecutive prime numbers.
One way or another we need to get an array of consecutive prime numbers .
def init_primes(prime_method, first, count)
    case prime_method
      when :fast 
        fast_primes(first,count)
      when :load 
        load_primes(first,count)
      when :calc 
        calc_primes(first,count)
    end 
  end
def init_primes ( prime_method , first , count ) case prime_method when :fast fast_primes ( first , count ) when :load load_primes ( first , count ) when :calc calc_primes ( first , count ) end end
One way or another, we need to get an array of consecutive prime numbers.
One way or another we need to get an array of consecutive prime numbers .
# Of course, we calculate the primes by default. But having three methods is not only # fancy; it's also comes in handy for testing that our calculated values are correct. # Using precalculated values from code. 8-17ms, mode 13ms on benchmark (2,10) run, 14-24ms/20ms on (200000,12) # Using precalculated values from file. 45-256ms, mode 50ms on benchmark (2,10) run, 669-913ms/681ms on (200000,12) # Using JS generated values. 14-84ms, Mode 18ms on benchmark (2,10) run, 17-25ms/21ms on (200000,12) # case prime_method
prime_method
<not_specific>
first
<not_specific>
count
<not_specific>