OFFSET
1,1
COMMENTS
This is the boustrophedon method of filling an array.
LINKS
Alois P. Heinz, Antidiagonals n = 1..45, flattened
EXAMPLE
Square array begins:
2, 3, 19, 11, 53, 47, ...
5, 13, 17, 43, 59, 103, ...
7, 23, 41, 61, 101, 127, ...
29, 37, 67, 97, 131, 181, ...
31, 71, 89, 137, 179, 229, ...
73, 83, 139, 173, 233, 283, ...
T(2,2) = 13 and not 11, because otherwise T(1,3)+7+11 = 0 (mod 3) would not be satisfied for any prime.
MAPLE
b:= proc(t) false end: T:= proc(n, k) local h, t, l, m; if n<1 or k<1 then t:=0 else h:= 1- 2* irem(n+k, 2); m:= n+k-1; l:= add(T(n+h*t, k-h*t), t=1..m-1); t:=3; while b(t) or (h=1 and (n=2 and igcd(t+l, m)>1 or n=1 and irem(t+l, m)<>0)) or (h=-1 and (k=2 and igcd(t+l, m)>1 or k=1 and irem(t+l, m)<>0)) do t:= nextprime(t) od fi; b(t):= true; T(n, k):=t end: T(1, 1):=2: seq(`if`(irem(d, 2)=1, seq(T(1+d-k, k), k=1..d), seq(T(n, 1+d-n), n=1..d)), d=1..15); # Alois P. Heinz, Oct 10 2009
MATHEMATICA
Clear[b]; b[_] = False; T[n_, k_] := Module[{h, t, l, m}, If[n<1 || k<1, t = 0, h = 1 - 2*Mod[n+k, 2]; m = n+k-1; l = Sum[T[n + h*t, k - h*t], {t, 1, m-1}]; t = 3; While[b[t] || (h == 1 && (n == 2 && GCD[t+l, m]>1 || n == 1 && Mod[t+l, m] != 0)) || (h == -1 && (k == 2 && GCD[t+l, m]>1 || k == 1 && Mod[t+l, m] != 0)), t = NextPrime[t]]]; b[t] = True; T[n, k] = t]; T[1, 1] = 2; Table[If[Mod[d, 2] == 1, Table[T[1+d-k, k], {k, 1, d}], Table [T[n, 1+d-n], {n, 1, d}]], {d, 1, 15}] // Flatten (* Jean-François Alcover, Jun 10 2015, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Amarnath Murthy, Apr 05 2003
EXTENSIONS
Edited with more terms by Alois P. Heinz, Oct 10 2009
STATUS
approved