cp's OEIS Frontend

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.

A323390 Total number of primes that are both left-truncatable and right-truncatable in base n.

Original entry on oeis.org

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, 20, 77, 13, 291, 15, 89, 27, 74, 20, 241, 18, 106, 25, 134, 15, 450, 23, 144, 33, 131, 24, 491, 27, 235, 29, 187, 23, 575, 30, 218, 31, 183, 25, 1377, 26, 247, 37, 231
Offset: 2

Views

Author

Daniel Suteu, Jan 13 2019

Keywords

Examples

			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.
		

Crossrefs

Programs

  • 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));