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.




void main() {
    import std.stdio, std.array, std.range, std.algorithm;
 
    enum n = 12;
    writefln("    %(%4d%)\n%s", iota(1, n+1), "-".replicate(4*n + 4));
    foreach (immutable y; 1 .. n + 1)
        writefln("%4d" ~ " ".replicate(4 * (y - 1)) ~ "%(%4d%)", y,
                 iota(y, n + 1).map!(x => x * y));
}