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.

A323137 Largest prime that is both left-truncatable and right-truncatable in base n.

This page as a plain text file.
%I A323137 #34 Mar 13 2019 03:34:04
%S A323137 23,11,67,839,37,1867,173,739397,79,105691,379,37573,647,3389,631,
%T A323137 202715129,211,155863,1283,787817,439,109893629,577,4195880189,1811,
%U A323137 14474071,379,21335388527,2203,1043557,2939,42741029,2767,50764713107,853,65467229,4409,8524002457
%N A323137 Largest prime that is both left-truncatable and right-truncatable in base n.
%H A323137 Daniel Suteu, <a href="/A323137/b323137.txt">Table of n, a(n) for n = 3..64</a>
%H A323137 Wikipedia, <a href="https://en.wikipedia.org/wiki/Truncatable_prime">Truncatable prime</a>
%F A323137 a(n) <= min(A023107(n), A103443(n)). - _Daniel Suteu_, Feb 24 2019
%e A323137 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.
%o A323137 (PARI)
%o A323137 digitsToNum(d, base) = sum(k=1, #d, base^(k-1) * d[k]);
%o A323137 isLeftTruncatable(d, base) = my(ok=1); for(k=1, #d, if(!isprime(digitsToNum(d[1..k], base)), ok=0; break)); ok;
%o A323137 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 A323137 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 A323137 a(n) = vecmax(bothTruncatablePrimesInBase(n)); \\ for n>=3; _Daniel Suteu_, Jan 22 2019
%Y A323137 Cf. A020994, A023107, A076586, A076623, A103443, A323390, A323396.
%K A323137 nonn,base
%O A323137 3,1
%A A323137 _Felix Fröhlich_, Jan 05 2019
%E A323137 a(17)-a(40) from _Daniel Suteu_, Jan 11 2019