The unique multiplication spiral This one is inspired by Calvin's Hobbies recent multiplication table challenge.

Write a function or program that takes an integer N as input and prints or returns a N-by-N unique multiplication spiral. The code must (in theory) work for N between 0 and 1000 (outputting this can be hard though). The output should be equivalent to the table produced by the following procedure:


Fill out an N-by-N multiplication table. E.g. for N = 3:

1 2 3
2 4 6
3 6 9

Follow a spiral clockwise from the upper left corner, noting the numbers that you visit. When you visit a number which you have already visited, replace it with 0.


A few examples might make it more clear:

n = 0:
0

n = 1:
1

n = 2:       //   Spiral order:
1  2         //   1  2
0  4         //   4  3

n = 3:
1  2  3      //   1  2  3
0  4  6      //   8  9  4
0  0  9      //   7  6  5

n = 4:
1  2  3  4   //   1   2   3   4
0  0  6  8   //  12  13  14   5
0  0  9 12   //  11  16  15   6
0  0  0 16   //  10   9   8   7

n = 5:
1   2   3   4   5
0   0   6   8  10
0   0   9  12  15
0   0   0  16  20
0   0   0   0  25

n = 10:
1   2   3   4   5   6   7   8   9  10
0   0   0   0   0  12  14  16  18  20
0   0   0   0  15   0  21  24  27  30
0   0   0   0   0   0  28  32  36  40
0   0   0   0  25   0  35   0  45  50
0   0   0   0   0   0  42  48  54  60
0   0   0   0   0   0  49  56  63  70
0   0   0   0   0   0   0  64  72  80
0   0   0   0   0   0   0   0  81  90
0   0   0   0   0   0   0   0   0 100


The numbers are found like this:



Any reasonable output format is accepted, but it must be an N-by-N matrix, it cannot be just a list. Formats such the ones below are accepted, as there are N easily distinguishable 1-by-N columns, or N-by-1 rows: 

[[1 2 3][0 4 6][0 0 9]]   &lt;-- OK

[[1 0 0][2 4 0][3 6 9]]   &lt;-- OK

ans =                     &lt;-- OK
    1  2  3
    0  4  6
    0  0  9   


Shortest code in bytes win.
Mathematica 123 122 117 98 92 73 bytes

With 24 bytes saved thanks to LegionMammal978 and another 19 by alephalpha !



Surprisingly, in this table, multiple instances of any whole number n will have the same relative ordering in the spiral as they do in the table itself! 
The first appearance of a number n lies at the very cell where that number appears first in the table (when one fills in the table row by row).  This means that the approach can disregard the spiral constraint altogether, for it has no bearing on the outcome.  (See explanation below.)

ReplacePart[t=1##&amp;~Array~{#,#},Join@@(Rest[t~Position~#]&amp;/@Union@@t)-&gt;0]&amp;




Example

ReplacePart[t=1##&amp;~Array~{#,#},Join@@(Rest[t~Position~#]&amp;/@Union@@t)-&gt;0]&amp;[10]



  {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {0, 0, 0, 0, 0, 12, 14, 16, 18, 
    20}, {0, 0, 0, 0, 15, 0, 21, 24, 27, 30}, {0, 0, 0, 0, 0, 0, 28, 32,
     36, 40}, {0, 0, 0, 0, 25, 0, 35, 0, 45, 50}, {0, 0, 0, 0, 0, 0, 42,
     48, 54, 60}, {0, 0, 0, 0, 0, 0, 49, 56, 63, 70}, {0, 0, 0, 0, 0, 0,
     0, 64, 72, 80}, {0, 0, 0, 0, 0, 0, 0, 0, 81, 90}, {0, 0, 0, 0, 0, 
    0, 0, 0, 0, 100}}




Grid[%]






Explanation

We exploit the fact that the spiral-order of the positions of any digit, n, is the same as the the order of row-col positions returned by the function, Positions!

The location of the first occurrence of each number (whether one orders by the spiral or by the table position) will be the first element returned by Position.  That first-occurrence cell will be left as it is. The remaining instances of the number are replaced by 0.

Let's look at how this works, examining for the case of n==18. The idea is to start with the multiplication table:

(t = Table[k Range@#, {k, #}] &amp;[10]) // Grid


and locate the row-col positions of each number.  For example, 18 is located at
Row 2, Col 9 (the first instance); Row 3, Col 6; Row 6, Col 3; and Row 9, Col 2.
These have the respective spiral-order positions {44, 58, 68, 82}.  

Position[t, 18]



  {{2, 9}, {3, 6}, {6, 3}, {9, 2}}


as the following table shows.



The final 3 instances of 18 need to be replaced by 0.  (We'll use a large bold blue zeros so they can be easily spotted.) 

ReplacePart[%, {{3, 6}, {6, 3}, {9, 2}} -&gt; Style[0, {Blue, Bold, 16}]]// Grid