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.




defmodule RC do
  def multiplication_tables(n) do
    IO.write " X |"
    Enum.each(1..n, fn i -> :io.fwrite("~4B", [i]) end)
    IO.puts "\n---+" <> String.duplicate("----", n)
    Enum.each(1..n, fn j ->
      :io.fwrite("~2B |", [j])
      Enum.each(1..n, fn i ->
        if i<j, do: (IO.write "    "), else: :io.fwrite("~4B", [i*j]) 
      end)
      IO.puts ""
    end)
  end
end
 
RC.multiplication_tables(12)