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.




/**
 Multiplication table, in Neko
 Tectonics:
   nekoc multiplication-table.neko
   neko multiplication-table
*/
 
var sprintf = $loader.loadprim("std@sprintf", 2);
 
var i, j;
 
i = 1;
$print("  X |");
while i < 13 {
  $print(sprintf("%4d", i));
  i += 1;
}
$print("\n");
$print(" ---+");
i = 1;
while i < 13 {
  $print("----");
  i += 1;
}
$print("\n");
 
j = 1;
while j < 13 {
  $print(sprintf("%3d", j));
  $print(" |");
  i = 1;
  while i < 13 {
    if j > i {
      $print("    ");
    } else {
      $print(sprintf("%4d", i*j));
    }
    i += 1;
  }
  $print("\n");
  j += 1;
}