This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A353591 #10 Jun 14 2022 06:57:11 %S A353591 0,1,2,3,4,5,6,9,8,7,10,11,16,17,12,13,14,23,18,25,15,19,22,31,26,29, %T A353591 21,20,24,35,30,27,28,32,33,34,36,49,40,39,46,38,41,44,37,42,48,43,54, %U A353591 45,51,52,55,58,47,50,53,57,56,59,69,70,63,66,81,60,61,78,65,67,64,68,73,72,79,76 %N A353591 Lexicographically earliest permutation of the nonnegative integers filling an infinite square array by falling antidiagonals so that the elements on any 2 X 2 square sum to a prime. %C A353591 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. %e A353591 The square array starts %e A353591 0 1 3 6 10 13 19 24 36 42 ... %e A353591 2 4 9 11 14 22 35 49 48 ... %e A353591 5 8 16 23 31 30 40 43 ... %e A353591 7 17 18 26 27 39 54 ... %e A353591 12 25 29 28 46 45 ... %e A353591 15 21 32 38 51 ... %e A353591 20 33 41 52 ... %e A353591 34 44 55 ... %e A353591 37 58 ... %e A353591 47 ... %e A353591 ... %e A353591 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. %e A353591 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. %o A353591 (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)} %Y A353591 Cf. A000040 (the primes), A337116 (same idea with square spiral instead of array by antidiagonals), A353590 (same idea with squares instead of primes). %K A353591 nonn %O A353591 0,3 %A A353591 _M. F. Hasler_, May 29 2022