Task

Produce a formatted   12×12   multiplication table of the kind memorized by rote when in primary (or elementary) school.



Only print the top half triangle of products.




def multiplication_table(n)
  puts "    |" + (" %3d" * n) % [*1..n]
  puts "----+" + "----" * n
  1.upto(n) do |x|
    print "%3d |" % x
    1.upto(x-1) {|y| print "    "}
    x.upto(n)   {|y| print " %3d" % (x*y)}
    puts
  end
end
 
multiplication_table 12