Module: Primegen::MultiplicationTable
- Defined in:
- lib/primegen/multiplication_table.rb
Class Method Summary collapse
-
.output(primes, n) ⇒ Object
Using Vectors to create rows and adding it to multiplication table.
Class Method Details
.output(primes, n) ⇒ Object
Using Vectors to create rows and adding it to multiplication table. Dropping 1 since it is not a prime number. Setting table title and row headings.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/primegen/multiplication_table.rb', line 10 def self.output(primes, n) table = Terminal::Table.new do |t| t.title = "Multiplcation table of first #{n} primes" primes.drop(1).each do |e| t << (Vector.elements(primes) * e).to_a end primes[0] = "X" t.headings = primes end table end |