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.

Showing 1-2 of 2 results.

A374965 a(n) = 2*a(n-1) + 1 for a(n-1) not prime, otherwise a(n) = prime(n) - 1; with a(1)=1.

Original entry on oeis.org

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
Offset: 1

Views

Author

Bill McEachen, Jul 25 2024

Keywords

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

Examples

			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.
		

Crossrefs

The primes are listed in A375028 (see also A373798 and A373804).
Cf. A050412 and A052333.

Programs

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

A373799 Index of n-th prime in A374965.

Original entry on oeis.org

2, 5, 9, 14, 19, 22, 25, 36, 38, 43, 47, 51, 56, 65, 72, 74, 76, 97, 100, 102, 105, 107, 110, 112, 115, 122, 125, 128, 130, 238, 255, 260, 272, 284, 286, 290, 293, 296, 300, 316, 325, 331, 562, 565, 567, 575, 578, 607, 610, 612, 617, 627, 632, 649, 651, 654, 866, 875, 878
Offset: 1

Views

Author

Harvey P. Dale and N. J. A. Sloane, Jul 28 2024

Keywords

Examples

			The fifth prime in order of appearance in A374965 is A375028(5) = 751 = A374965(19), so a(5) = 19.
		

Crossrefs

Cf. A373798 (first differences), A374965, A375028.

Programs

  • Python
    from itertools import count, islice
    from sympy import isprime, nextprime
    def A373799_gen(): # generator of terms
        a, p = 1, 3
        for i in count(1):
            if isprime(a):
                yield i
                a = p-1
            else:
                a = (a<<1)+1
            p = nextprime(p)
    A373799_list = list(islice(A373799_gen(),20)) # Chai Wah Wu, Jul 29 2024
Showing 1-2 of 2 results.