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 A137812 #53 Feb 16 2025 08:33:07 %S A137812 2,3,5,7,13,17,23,29,31,37,43,47,53,59,67,71,73,79,83,97,113,131,137, %T A137812 139,167,173,179,197,223,229,233,239,271,283,293,311,313,317,331,337, %U A137812 347,353,359,367,373,379,383,397,431,433,439,443,467,479,523,547,571 %N A137812 Left- or right-truncatable primes. %C A137812 Repeatedly removing a digit from either the left or right produces only primes. There are 149677 terms in this sequence, ending with 8939662423123592347173339993799. %C A137812 The number of n-digit terms is A298048(n). - _Jon E. Schoenfield_, Jan 28 2022 %H A137812 T. D. Noe, <a href="/A137812/b137812.txt">Table of n, a(n) for n = 1..10000</a> %H A137812 I. O. Angell and H. J. Godwin, <a href="http://dx.doi.org/10.1090/S0025-5718-1977-0427213-2">On Truncatable Primes</a>, Math. Comput. 31, 265-267, 1977. %H A137812 T. D. Noe, <a href="/A137812/a137812.png">Plot of all terms</a> %H A137812 Carlos Rivera, <a href="http://www.primepuzzles.net/puzzles/puzz_002.htm">Puzzle 2: Prime Strings</a>, The Prime Puzzles and Problems Connection. %H A137812 Daniel Starodubtsev, <a href="/A137812/a137812_1.txt">Full sequence</a> %H A137812 Eric Weisstein, <a href="https://mathworld.wolfram.com/TruncatablePrime.html">MathWorld: Truncatable Prime</a> %H A137812 <a href="/index/Tri#tprime">Index entries for sequences related to truncatable primes</a> %e A137812 139 is here because (removing 9 from the right) 13 is prime and (removing 1 from the left) 3 is prime. %t A137812 Clear[s]; s[0]={2,3,5,7}; n=1; While[s[n]={}; Do[k=s[n-1][[i]]; Do[p=j*10^n+k; If[PrimeQ[p], AppendTo[s[n],p]], {j,9}]; Do[p=10*k+j; If[PrimeQ[p], AppendTo[s[n],p]], {j,9}], {i,Length[s[n-1]]}]; s[n]=Union[s[n]]; Length[s[n]]>0, n++ ];t=s[0]; Do[t=Join[t,s[i]], {i,n}]; t %o A137812 (Python) %o A137812 from sympy import isprime %o A137812 def agen(): %o A137812 primes = [2, 3, 5, 7] %o A137812 while len(primes) > 0: %o A137812 yield from primes %o A137812 cands = set(int(d+str(p)) for p in primes for d in "123456789") %o A137812 cands |= set(int(str(p)+d) for p in primes for d in "1379") %o A137812 primes = sorted(c for c in cands if isprime(c)) %o A137812 afull = [an for an in agen()] %o A137812 print(afull[:60]) # _Michael S. Branicky_, Aug 04 2022 %Y A137812 Cf. A024770 (right-truncatable primes), A024785 (left-truncatable primes), A077390 (left-and-right truncatable primes), A080608. %Y A137812 Cf. A298048 (number of n-digit terms). %K A137812 base,fini,nonn %O A137812 1,1 %A A137812 _T. D. Noe_, Feb 11 2008