How to resolve the algorithm Multiplication tables step by step in the Elixir programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Multiplication tables step by step in the Elixir programming language
Table of Contents
Problem Statement
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.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Multiplication tables step by step in the Elixir programming language
Source code in the elixir programming language
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)
You may also check:How to resolve the algorithm Special characters step by step in the HTML programming language
You may also check:How to resolve the algorithm Longest common substring step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Concurrent computing step by step in the OCaml programming language
You may also check:How to resolve the algorithm Sudan function step by step in the BQN programming language
You may also check:How to resolve the algorithm Repeat a string step by step in the 68000 Assembly programming language