OFFSET
1,1
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
AUTHOR
Jean-Marc Rebert, Aug 06 2024
STATUS
approved