login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A232129 Largest prime that can be obtained from n by successively appending digits to the right with the constraint that each of the numbers obtained that way must be prime; a(n)=0 if there is no such prime at all. 3

%I #14 Sep 07 2021 09:28:45

%S 1979339339,29399999,37337999,4391339,59393339,6733997,73939133,839,

%T 9719,103997939939,113,12791333,13999133,149399,15797,1637,17333,

%U 1811993,1979339339,0,21139,2273993,23399339,24179399,2579939,2699393,27191939,2837,29399999,3079,31379,0,331999799,3491333,35393999

%N Largest prime that can be obtained from n by successively appending digits to the right with the constraint that each of the numbers obtained that way must be prime; a(n)=0 if there is no such prime at all.

%C See A232128 for the number of steps required to reach a(n), equal to the length of a(n) minus the length of n. See A232126 for a variant "working backwards", where truncation is considered.

%H Michael S. Branicky, <a href="/A232129/b232129.txt">Table of n, a(n) for n = 1..10000</a>

%H Archimedes' Lab, <a href="http://www.archimedes-lab.org/numbers/Num24_69.html">What's Special About This Number?</a>, section about 43.

%e Starting with 8, one can get the primes 83 and 89 which is larger, but 83 allows one further extension to 839 while 89 does not (no prime in the range 890..899. No further extension is possible, since there are no primes in the range 8390,...,8399. Therefore a(8)=839 and A232128(8)=2.

%e a(20)=a(42)=0 since no prime can be obtained by appending one digit to 20 or 42.

%o (PARI) {A232129(n)=local(t(p)=my(m,r=[0,p]);forstep(d=1,9,2,isprime(p*10+d)&&(m=t(10*p+d)+[1,0])[1]>=r[1]&&r=m);r);n<(n=t(n))[2]&&return(n[2])}

%o (Python)

%o from sympy import isprime, nextprime

%o def a(n):

%o while True:

%o extends, reach, maxp = -1, {n}, 0

%o while len(reach) > 0:

%o candidates = (int(str(e)+d) for d in "1379" for e in reach)

%o reach1 = set(filter(isprime, candidates))

%o extends, reach, maxp = extends+1, reach1, max({maxp}|reach1)

%o return maxp

%o print([a(n) for n in range(1, 36)]) # _Michael S. Branicky_, Sep 07 2021

%Y Cf. A232128, A232127, A232126, A232125.

%K nonn,base

%O 1,1

%A _M. F. Hasler_, Nov 19 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 19:02 EDT 2024. Contains 371798 sequences. (Running on oeis4.)