OFFSET
2,2
LINKS
Chris Caldwell, right-truncatable prime, The Prime Glossary.
Eric Weisstein's World of Mathematics, Truncatable Prime
EXAMPLE
For n = 2, there are no both-truncatable primes, therefore a(2) = 0.
For n = 3, there are 2 both-truncatable primes: 2, 23.
For n = 4, there are 3 both-truncatable primes: 2, 3, 11.
For n = 5, there are 5 both-truncatable primes: 2, 3, 13, 17, 67.
For n = 6, there are 9 both-truncatable primes: 2, 3, 5, 17, 23, 83, 191, 479, 839.
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) = #(bothTruncatablePrimesInBase(n));
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Daniel Suteu, Jan 13 2019
STATUS
approved