OFFSET
0,3
COMMENTS
In A337116 the infinite 2D lattice is filled along a square spiral satisfying the same constraint of 2 X 2 squares adding up to primes.
EXAMPLE
The square array starts
0 1 3 6 10 13 19 24 36 42 ...
2 4 9 11 14 22 35 49 48 ...
5 8 16 23 31 30 40 43 ...
7 17 18 26 27 39 54 ...
12 25 29 28 46 45 ...
15 21 32 38 51 ...
20 33 41 52 ...
34 44 55 ...
37 58 ...
47 ...
...
a(4) is in the second row and column. It must sum up with a(0) = 0, a(1) = 1 and a(2) = 2 to a prime. The smallest possible solution is to reach the prime p = 7 with a(4) = 4.
Similarly, a(7) which is on the second row, third column, must sum up with a(1) = 1 (above to the left), a(3) = 3 (above) and a(4) = 4 (to the left) to a prime; the smallest solution is to reach the prime p = 17 using a(7) = 9.
PROG
(PARI) A353591_upto(N, M=Map(), r, c, U=[-1])={vector(N, i, if(r && c, my(s=mapget(M, [r-1, c-1])+mapget(M, [r-1, c])+mapget(M, [r, c-1]), p=nextprime(s+U[1]+1)); while(setsearch(U, N=p-s), p=nextprime(p+1)), N=U[1]+1); mapput(M, [r, c], N); if(c, c--; r++, r=!c=r+1); U=setunion(U, [N]); while(#U>1 && U[2]==U[1]+1, U=U[^1]); N)}
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, May 29 2022
STATUS
approved