Print multiplication tables
Spike gave a nice answer already. I just wanted to point out one thing: This is a good use case for rjust, aka "right-justify". With that, you can skip the string-multiplication when you pad the numbers.

def print_multiplication_table(max)
  padding = (max * max).to_s.length + 1
  sequence = (1..max).to_a
  puts sequence.product(sequence)
    .map { |a, b| (a * b).to_s.rjust(padding) }
    .each_slice(max)
    .map(&amp;:join)
    .join("\n")
end


This one only uses 1 space between columns, but 2 spaces can be had by replacing .map(&amp;:join) with .map { |row| row.join(" ") }.