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-4 of 4 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

A373798 Divide A374965 into "blocks" by saying that each prime term ends a block; sequence gives lengths of successive blocks.

Original entry on oeis.org

2, 3, 4, 5, 5, 3, 3, 11, 2, 5, 4, 4, 5, 9, 7, 2, 2, 21, 3, 2, 3, 2, 3, 2, 3, 7, 3, 3, 2, 108, 17, 5, 12, 12, 2, 4, 3, 3, 4, 16, 9, 6, 231, 3, 2, 8, 3, 29, 3, 2, 5, 10, 5, 17, 2, 3, 212, 9, 3, 4, 5, 22, 3, 5, 13, 5, 9, 4, 12, 8, 2, 57, 2, 65, 5, 3, 93, 9, 46
Offset: 1

Views

Author

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

Keywords

Comments

The first 286 terms of the sequence are the result of dividing the first 10000 terms of A374965 into "blocks."
Comment from N. J. A. Sloane, Aug 09 2024 (Start):
Suppose p = A374965(t) is a prime in A374965, and is the s-th prime to appear there (that is, A375028(s) = p and A373799(s) = t). The next term in A374965 is by definition A374965(t+1) = prime(t+1) - 1 = r (say). Then the block starting with r has length a(s+1) = A050412(r) + 1. For example, p = 19 = A374965(5) is the second prime in A374695, so we have s = 2, t = 5, and r = prime(6) - 1 = 13 - 1 = 12. Then A050412(12) = 3, which tells us that a(3) = 3 + 1 = 4. The block is [12, 25, 51, 103].
For a larger example, the s = 285th prime in A374965 is p = 160077823 = A374965(7686), so t = 7686. The next block begins with r = prime(7687) - 1 = 78282. After 39 steps of double-and-add-1 (corresponding to A050412(78282) = 39) we reach the 286th prime in A374965, A374965(7726) = 43036534378594303. (End)

Examples

			A374965 begins
1, 3/ 4, 9, 19/ 12, 25, 51, 103/ 28, 57, 115, 231, 463/ 46, 93, 187, 375, 751/ 70, 141, 283/ 82, 165, ...,
where the primes are followed by slashes, to indicate the blocks. The lengths of the initial blocks are 2, 3, 4, 5, 5, 3, ...
		

Crossrefs

Programs

  • Mathematica
    nxt[{n_, a_}] := {n + 1, If[! PrimeQ[a], 2 a + 1, Prime[n + 1] - 1]}; vvv=NestList[nxt,{1,1},9999][[;;,2]]; Total/@Partition[Length/@SplitBy[vvv,PrimeQ],2] (* Harvey P. Dale, Jul 28 2024 *)

A373804 Primes in A374965 sorted into increasing order.

Original entry on oeis.org

3, 19, 103, 283, 313, 331, 463, 733, 751, 757, 1093, 1153, 1213, 1453, 1543, 1783, 2083, 2251, 2371, 2467, 2671, 2707, 2803, 3733, 3823, 7603, 7723, 8221, 9013, 9661, 14983, 15277, 15607, 16363, 16381, 16843, 17923, 19483, 20287, 21061, 22093, 23173, 24421, 24841, 25903, 27211, 28411
Offset: 1

Views

Author

N. J. A. Sloane, Aug 08 2024

Keywords

Comments

Since we know the first 350199 terms of A374965, and A374965(350199) = 5026186 starts a new doubling chain, we know that any subsequent prime is greater than 5026186. This implies that the terms in the b-file, which are < 5026186, are correct. Of course, if the sequence reaches a Riesel number (cf. A076337) there will be no more primes after that point.
Note that, as can be seen from the b-file in A375028, A374965 contains many primes greater than 5026186 among the first 350199 terms, including one prime with 102410 digits. But these large primes cannot be added to the present b-file until more is discovered about primes following term 350199.

Crossrefs

Showing 1-4 of 4 results.