login
A375171
Square array T(n,k), n>0 and k>0, read by antidiagonals in ascending order, giving the smallest n*k-digit number that, if arranged in an n X k matrix, form k-digit reversible prime in each row and n-digit reversible prime in each column, or -1 if no such number exists.
1
2, 37, 37, 337, 1111, 337, 3257, 111331, 113131, 3257, 32233, 13139731, 113101311, 11933371, 32233, 322573, 1111179779, 113101929311, 119310213191, 1119711779, 322573, 3222223, 111111131397, 113101167919739, 1193100990013911, 111971042937997, 111119111337, 3222223
OFFSET
1,1
FORMULA
T(1,n) = T(n,1) <= A177513(n) for n >1.
T(1,n) = T(n,1) = A177513(n) for n = 2..6.
EXAMPLE
T(3,2) = 111331 is the smallest 3*2-digit number that if arranged in a 3 X 2 matrix yields in each row and column an reversible prime, i.e.,
11
13
31
-> 11 (1 time), 13 (1 time), 31 (1 time), 113 (1 time), 131 (1 time) are all reversible primes.
Table begins (upper left corner = T(1,1)):
2 37 337 3257 ...
37 1111 113131 11933371 ...
337 111331 113101311 119310213191 ...
3257 13139731 113101929311 1193100990013911 ...
... ... ... ... ...
PROG
(PARI)
isp(x) = ispseudoprime(x) && ispseudoprime(fromdigits(Vecrev(digits((x)))));
ispd(x) = ispseudoprime(fromdigits(x)) && ispseudoprime(fromdigits(Vecrev(x)));
vp(n) = select(isp, [10^(n-1)..10^n-1]);
isok(val, n, k) = my(d=digits(val), v=vector(k, i, []), j=1); for (i=1, #d, v[j] = concat(v[j], d[i]); j++; if (j>k, j=1); ); for (i=1, k, if (!ispd(v[i]), return(0)); ); return(1);
T(n, k) = my(v = vp(k), nbp = #v, nb = nbp^n); for (i=0, nb-1, my(d=digits(i, nbp)); if (d==[], d=vector(n)); while(#d <n, d=concat(0, d)); d = apply(x->x+1, d); my(s=""); for (i=1, #d, s = concat(s, Str(v[d[i]]))); my(val = eval(s)); if (isok(val, n, k), return(val)); ); \\ Michel Marcus, Aug 08 2024
CROSSREFS
KEYWORD
tabl,base,nonn
AUTHOR
Jean-Marc Rebert, Aug 06 2024
STATUS
approved