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!)
A374965 a(n) = 2*a(n-1) + 1 for a(n-1) not prime, otherwise a(n) = prime(n) - 1; with a(1)=1. 6
1, 3, 4, 9, 19, 12, 25, 51, 103, 28, 57, 115, 231, 463, 46, 93, 187, 375, 751, 70, 141, 283, 82, 165, 331, 100, 201, 403, 807, 1615, 3231, 6463, 12927, 25855, 51711, 103423, 156, 313, 166, 333, 667, 1335, 2671, 192, 385, 771, 1543, 222, 445, 891, 1783, 238, 477 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
Sequence is clearly infinite and not monotonic. Primes are sparse.
When is the next prime after n=10016 ? [Answer from N. J. A. Sloane, Aug 01 2024: The point of Bill's question is that a(10016) is the prime 838951, which is in fact the 289th prime in this sequence, as can be seen from A375028 and A373799. Thanks to the work of Lucas A. Brown (see A050412), we now know that the answer to Bill's question is that the 290th prime is the 102410-digit prime 104917*2^340181 - 1 = 5079...8783, which is a(350198). It was a very good question!]
It appears that the trajectories for different initial conditions a(1) converge to a few attractors. For all prime values and most nonprime values of a(1), the trajectories converge to the same attractor with prime 838951 at n=10016. For a(1) = 147, 295, 591, 1183, ... the trajectories converge to prime 85796863 at n=4390. For a(1) = 658, the trajectory reaches a prime with 240983 digits after 800516 steps. For a(1) = 509202, the trajectory never reaches a prime (see A050412, A052333). - Chai Wah Wu, Jul 29 2024
LINKS
EXAMPLE
a(1) = 1 is not a prime, so a(2) = 2*1+1 = 3. a(2) is a prime, so a(3) = prime(3)-1 = 4. a(4) = 2*4+1 = 9.
MATHEMATICA
a[n_] := a[n] = If[!PrimeQ[a[n-1]], 2*a[n-1] + 1, Prime[n]-1]; a[1] = 1; Array[a, 60] (* Amiram Eldar, Jul 25 2024 *)
nxt[{n_, a_}]:={n+1, If[!PrimeQ[a], 2a+1, Prime[n+1]-1]}; NestList[nxt, {1, 1}, 60][[;; , 2]] (* Harvey P. Dale, Jul 28 2024 *)
PROG
(Python)
from itertools import islice
from sympy import isprime, nextprime
def A374965_gen(): # generator of terms
a, p = 1, 3
while True:
yield a
a, p = p-1 if isprime(a) else (a<<1)+1, nextprime(p)
A374965_list = list(islice(A374965_gen(), 30)) # Chai Wah Wu, Jul 29 2024
CROSSREFS
The primes are listed in A375028 (see also A373798 and A373804).
Cf. A050412 and A052333.
Sequence in context: A352134 A304257 A217492 * A178784 A192288 A028344
KEYWORD
nonn,easy,new
AUTHOR
Bill McEachen, Jul 25 2024
STATUS
approved

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 August 8 23:13 EDT 2024. Contains 375024 sequences. (Running on oeis4.)