OFFSET
1,2
COMMENTS
Row 1: numbers k such that k = 1 or k = 2 or (k - 1 or k + 1) is a prime.
Row r > 1: numbers k such that k + r or k - r is a prime but k + q and k - q are not, for q = 1, 2, ..., r - 1.
Every positive integer occurs exactly once, so that as a sequence, A192178 is a permutation of the positive integers.
For r > 1, the numbers in row r have the parity of r - 1; e.g., the numbers in row 2 are odd.
EXAMPLE
Northwest corner:
1....2....3....4....6....8....10
5....7....9....11...13...15...17
26...34...50...56...64...76...86
23...37...47...67...79...83...93
118..122..144..186..204..206..216
...
For example, 34 is in row 3 recause its distance to the nearest prime is 3.
MATHEMATICA
z = 5000; (* z = number of primes used *)
row[1] = (#1[[1]] &) /@ Cases[Array[{#1, PrimeQ[#1 - 1] || PrimeQ[#1 + 1] || #1 == 1 || #1 == 2} &, {z}], {_, True}];
Do[row[x] = Complement[(#1[[1]] &) /@ Cases[Array[{#1, PrimeQ[#1 - x] || PrimeQ[#1 + x]} &, {z}], {_, True}], Flatten[Array[row, {x - 1}]]], {x, 2, 10}];
TableForm[Array[row, {10}]] (* A192178 array *)
Flatten[Table[row[k][[n - k + 1]], {n, 1, 11}, {k, 1,
n}]] (* A192178 sequence *)
(* by Peter J. C. Moses, Jun 24 2011 *)
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Clark Kimberling, Jun 24 2011
STATUS
approved