How to resolve the algorithm Multiplication tables step by step in the Picat programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Multiplication tables step by step in the Picat 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 Picat programming language
Source code in the picat programming language
go =>
N=12,
make_table(N),
nl.
%
% Make a table of size N
%
make_table(N) =>
printf(" "),
foreach(I in 1..N) printf("%4w", I) end,
nl,
println(['-' : _ in 1..(N+1)*4+1]),
foreach(I in 1..N)
printf("%2d | ", I),
foreach(J in 1..N)
if J>=I then
printf("%4w", I*J)
else
printf(" ")
end
end,
nl
end,
nl.
You may also check:How to resolve the algorithm Rosetta Code/Fix code tags step by step in the Delphi programming language
You may also check:How to resolve the algorithm Chaocipher step by step in the Objeck programming language
You may also check:How to resolve the algorithm String prepend step by step in the Maple programming language
You may also check:How to resolve the algorithm Active object step by step in the zkl programming language
You may also check:How to resolve the algorithm JSON step by step in the PHP programming language