OFFSET
3,1
LINKS
Daniel Suteu, Table of n, a(n) for n = 3..64
Wikipedia, Truncatable prime
FORMULA
EXAMPLE
For n = 12: 105691 is 511B7 in base 12. Successively removing the leftmost digit yields the base-12 numbers 11B7, 1B7, B7 and 7. When converted to base 10, these are 2011, 283, 139 and 7, respectively, all primes. Successively removing the rightmost digit yields the base-12 numbers 511B, 511, 51 and 5. When converted to base 10, these are 8807, 733, 61 and 5, respectively, all primes. Since no larger prime with this property in base 12 exists (as proven by Daniel Suteu), a(12) = 105691.
PROG
(PARI)
digitsToNum(d, base) = sum(k=1, #d, base^(k-1) * d[k]);
isLeftTruncatable(d, base) = my(ok=1); for(k=1, #d, if(!isprime(digitsToNum(d[1..k], base)), ok=0; break)); ok;
generateFromPrefix(p, base) = my(seq = [p]); for(n=1, base-1, my(t=concat(n, p)); if(isprime(digitsToNum(t, base)), seq=concat(seq, select(v -> isLeftTruncatable(v, base), generateFromPrefix(t, base))))); seq;
bothTruncatablePrimesInBase(base) = my(t=[]); my(P=primes(primepi(base-1))); for(k=1, #P, t=concat(t, generateFromPrefix([P[k]], base))); vector(#t, k, digitsToNum(t[k], base));
a(n) = vecmax(bothTruncatablePrimesInBase(n)); \\ for n>=3; Daniel Suteu, Jan 22 2019
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Felix Fröhlich, Jan 05 2019
EXTENSIONS
a(17)-a(40) from Daniel Suteu, Jan 11 2019
STATUS
approved