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.




/* Print N-by-N multiplication table */
proc nonrec multab(byte n) void:
    byte i,j;
 
    /* write header */
    write("    |");
    for i from 1 upto n do write(i:4) od;
    writeln();
    write("----+");
    for i from 1 upto n do write("----") od;
    writeln();
 
    /* write lines */
    for i from 1 upto n do
        write(i:4, "|");
        for j from 1 upto n do
            if i <= j then write(i*j:4)
            else write("    ")
            fi
        od;
        writeln()
    od
corp
 
/* Print 12-by-12 multiplication table */
proc nonrec main() void: multab(12) corp