Print the f × f times table

Jelly, 12 bytes

⁴Ḷ×þ`d⁴‘ịØhG

Try it online!

How it works

⁴Ḷ×þ`d⁴‘ịØhG  Main link. No arguments.

⁴             Set the return value to 16.
 Ḷ            Unlength; yield [0, ..., 15].
  ×þ`         Build the multiplication table of [0, ..., 15] and itself.
     d⁴       Divmod 16; yield [p : 16, p % 16] for each product p.
       ‘      Increment quotients and remainders (1-based indexing).
        ịØh   Index into the lowercase hexadecimal alphabet.
           G  Grid; join columns by spaces, rows by newlines.

Python 2, 60 bytes

for n in range(256):r=n%16;print'%02x%s'%(n/16*r,r/15*'\n'),

Try it online!

How it works

For all integers n from 0 to 255, we do the following.

  • We compute (n / 16) × (n % 16).

    Over the range of n, both n / 16 and n % 16 independently cover the range 0, …, 15, so this generates all entries of the multiplication table.

  • We repeat the linefeed character ('\n') (n % 16) / 15 times, which results in the same character when n % 16 = 15 and an empty string otherwise.

  • The format string '%02x%s' turns the two previous results into a single string, first a lowercase hexadecimal integer representation, zero-padded to (at least) two digits, then the generated string.

  • Finally, print..., prints the formatted results.

    Since the print statement ends with a comma, Python will not append a linefeed. Also, before printing the next string, Python will prepend a space unless we're at the beginning of a new line. (source) This happens to format the output exactly like we want to.


R, 42 bytes

as.hexmode(sapply(0:15,function(x)x*0:15))

Prints the following:

      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16]
 [1,] "00" "00" "00" "00" "00" "00" "00" "00" "00" "00"  "00"  "00"  "00"  "00"  "00"  "00" 
 [2,] "00" "01" "02" "03" "04" "05" "06" "07" "08" "09"  "0a"  "0b"  "0c"  "0d"  "0e"  "0f" 
 [3,] "00" "02" "04" "06" "08" "0a" "0c" "0e" "10" "12"  "14"  "16"  "18"  "1a"  "1c"  "1e" 
 [4,] "00" "03" "06" "09" "0c" "0f" "12" "15" "18" "1b"  "1e"  "21"  "24"  "27"  "2a"  "2d" 
 [5,] "00" "04" "08" "0c" "10" "14" "18" "1c" "20" "24"  "28"  "2c"  "30"  "34"  "38"  "3c" 
 [6,] "00" "05" "0a" "0f" "14" "19" "1e" "23" "28" "2d"  "32"  "37"  "3c"  "41"  "46"  "4b" 
 [7,] "00" "06" "0c" "12" "18" "1e" "24" "2a" "30" "36"  "3c"  "42"  "48"  "4e"  "54"  "5a" 
 [8,] "00" "07" "0e" "15" "1c" "23" "2a" "31" "38" "3f"  "46"  "4d"  "54"  "5b"  "62"  "69" 
 [9,] "00" "08" "10" "18" "20" "28" "30" "38" "40" "48"  "50"  "58"  "60"  "68"  "70"  "78" 
[10,] "00" "09" "12" "1b" "24" "2d" "36" "3f" "48" "51"  "5a"  "63"  "6c"  "75"  "7e"  "87" 
[11,] "00" "0a" "14" "1e" "28" "32" "3c" "46" "50" "5a"  "64"  "6e"  "78"  "82"  "8c"  "96" 
[12,] "00" "0b" "16" "21" "2c" "37" "42" "4d" "58" "63"  "6e"  "79"  "84"  "8f"  "9a"  "a5" 
[13,] "00" "0c" "18" "24" "30" "3c" "48" "54" "60" "6c"  "78"  "84"  "90"  "9c"  "a8"  "b4" 
[14,] "00" "0d" "1a" "27" "34" "41" "4e" "5b" "68" "75"  "82"  "8f"  "9c"  "a9"  "b6"  "c3" 
[15,] "00" "0e" "1c" "2a" "38" "46" "54" "62" "70" "7e"  "8c"  "9a"  "a8"  "b6"  "c4"  "d2" 
[16,] "00" "0f" "1e" "2d" "3c" "4b" "5a" "69" "78" "87"  "96"  "a5"  "b4"  "c3"  "d2"  "e1"