How to resolve the algorithm Multiplication tables step by step in the Seed7 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Multiplication tables step by step in the Seed7 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 Seed7 programming language

Source code in the seed7 programming language

$ include "seed7_05.s7i";
 
const proc: main is func
  local
    const integer: n is 12;
    var integer: i is 0;
    var integer: j is 0;
  begin
    for j range 1 to n do
      write(j lpad 3 <& " ");
    end for;
    writeln;
    writeln("-" mult 4 * n);
    for i range 1 to n do
      for j range 1 to n do
        if j < i then
          write("    ");
        else
          write(i * j lpad 3 <& " ");
        end if;
      end for;
      writeln("|" <& i lpad 3);
    end for;
  end func;

  

You may also check:How to resolve the algorithm Machine code step by step in the BBC BASIC programming language
You may also check:How to resolve the algorithm Last letter-first letter step by step in the OpenEdge/Progress programming language
You may also check:How to resolve the algorithm Collections step by step in the PL/I programming language
You may also check:How to resolve the algorithm Duffinian numbers step by step in the Raku programming language
You may also check:How to resolve the algorithm Non-continuous subsequences step by step in the D programming language