# Creating table that omits certain values

Say I want to run a function of the form

Table[i*j,{i,-5,5},{j,-5,5}]


but I want to omit all the values of $$|i|\leq1$$ and $$|j|\leq1$$. In other words, how do I create my 2D grid of values that doesn't contain the box of length 2 centered at the origin.

How would I write this in a general form rather than making the table by hand?

• You mean you want to skip $i=-1,0,1$ and $j=-1,0,1$? Apr 27, 2020 at 16:37
• Yes, exactly. I want to skip the 9 pairs ${i,j}$ where $i=-1,0,1$, $j=-1,0,1$ Apr 27, 2020 at 16:40

And just for fun, here is another approach

Flatten[Table[If[Abs[i]<= 1 || Abs[j] <=1, Nothing[], i*j], {i, -5, 5}, {j, -5, 5}], {2}] • My question was probably not sufficiently clear. This is what I was looking for but exchanging the Or ( || ) for an And ( && ). Thanks! Apr 27, 2020 at 17:20

One approach is to explicitly set the range for the variables:

ran = Select[Range[-5, 5], Abs[#] > 1 &];
Table[i*j, {i, ran}, {j, ran}]


Another one to try to get me to 10K.

With[{r = Join[#, -Reverse@#] &@Range[-5, -2]}, Table[i j, {i, r}, {j, r}]]