module Multiprime
Constants
- VERSION
Public Class Methods
primes()
click to toggle source
# File lib/multiprime.rb, line 10 def self.primes 2.upto(Float::INFINITY).lazy.select { |n| 2.upto(Math.sqrt(n)).none? { |i| n % i == 0 } } end
table(size)
click to toggle source
# File lib/multiprime.rb, line 5 def self.table(size) range = primes.take(size).to_a return range.map { |x| range.map { |y| x * y } }, range end