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 A323390 #27 Feb 16 2025 08:33:57 %S A323390 0,2,3,5,9,7,22,8,15,6,35,11,37,17,22,12,69,12,68,18,44,13,145,16,47, %T A323390 20,77,13,291,15,89,27,74,20,241,18,106,25,134,15,450,23,144,33,131, %U A323390 24,491,27,235,29,187,23,575,30,218,31,183,25,1377,26,247,37,231 %N A323390 Total number of primes that are both left-truncatable and right-truncatable in base n. %H A323390 Chris Caldwell, <a href="https://primes.utm.edu/glossary/page.php?sort=RightTruncatablePrime">right-truncatable prime</a>, The Prime Glossary. %H A323390 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/TruncatablePrime.html">Truncatable Prime</a> %e A323390 For n = 2, there are no both-truncatable primes, therefore a(2) = 0. %e A323390 For n = 3, there are 2 both-truncatable primes: 2, 23. %e A323390 For n = 4, there are 3 both-truncatable primes: 2, 3, 11. %e A323390 For n = 5, there are 5 both-truncatable primes: 2, 3, 13, 17, 67. %e A323390 For n = 6, there are 9 both-truncatable primes: 2, 3, 5, 17, 23, 83, 191, 479, 839. %o A323390 (PARI) %o A323390 digitsToNum(d, base) = sum(k=1, #d, base^(k-1) * d[k]); %o A323390 isLeftTruncatable(d, base) = my(ok=1); for(k=1, #d, if(!isprime(digitsToNum(d[1..k], base)), ok=0; break)); ok; %o A323390 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; %o A323390 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)); %o A323390 a(n) = #(bothTruncatablePrimesInBase(n)); %Y A323390 Cf. A020994, A076623, A076586, A323137, A323396. %K A323390 nonn,base %O A323390 2,2 %A A323390 _Daniel Suteu_, Jan 13 2019