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.

A308334 Lexicographically earliest sequence of distinct positive numbers such that for any n > 0, a(n) OR a(n+1) is a prime number (where OR denotes the bitwise OR operator).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 16, 13, 8, 11, 9, 10, 21, 12, 17, 14, 19, 15, 18, 23, 20, 25, 22, 27, 28, 29, 24, 31, 26, 33, 36, 37, 32, 41, 34, 43, 35, 40, 39, 42, 45, 38, 47, 44, 49, 52, 53, 48, 59, 50, 57, 51, 56, 61, 60, 67, 62, 65, 63, 64, 71, 58, 69, 66, 77, 54
Offset: 1

Views

Author

Rémy Sigrist, May 20 2019

Keywords

Comments

By Dirichlet's theorem on arithmetic progressions, we can always extend the sequence: say a(n) < 2^k, then a(n) OR 1 and 2^k are coprime and there are infinitely many prime numbers of the form (a(n) OR 1) + m*2^k = a(n) OR (1 + m*2^k) and we can extend the sequence.
Will every integer appear in this sequence?
Numerous sequences are based on the same model: the sequence is the lexicographically earliest sequence of distinct positive terms such that some function in two variables yields prime numbers when applied to consecutive terms:
f(u,v) Analog sequence
------- -----------------
u OR v a (this sequence)
u + v A055265
u*v + 1 A073666
u*v - 1 A081943
abs(u-v) A065186
max(u,v) A282649
u^2 + v^2 A100208
The appearance of numbers much earlier or later than their corresponding index is flagged strikingly in the plot2 graph of a(n)/n (see links). - Peter Munn, Sep 10 2022

Examples

			The first terms, alongside a(n) OR a(n+1), are:
  n   a(n)  a(n) OR a(n+1)
  --  ----  --------------
   1     1               3
   2     2               3
   3     3               7
   4     4               5
   5     5               7
   6     6               7
   7     7              23
   8    16              29
   9    13              13
  10     8              11
  11    11              11
  12     9              11
		

Crossrefs

See A308340 for the corresponding prime numbers.
See A055265, A065186, A073666, A081943, A100208, A282649 for similar sequences.

Programs

  • PARI
    s=0; v=1; for (n=1, 67, s+=2^v; print1 (v ", "); for (w=1, oo, if (!bittest(s,w) && isprime(o=bitor(v,w)), v=w; break)))
    
  • Python
    from sympy import isprime
    from itertools import count, islice
    def agen():
        aset, k, mink = {1}, 1, 2
        for n in count(1):
            an = k; yield an; aset.add(an)
            s, k = set(str(an)), mink
            while k in aset or not isprime(an|k): k += 1
            while mink in aset: mink += 1
    print(list(islice(agen(), 67))) # Michael S. Branicky, Sep 10 2022

A308598 The smaller term of the pair (a(n), a(n+1)) is always prime and in each pair there is a composite number; a(1) = 2 and the sequence is always extended with the smallest integer not yet present and not leading to a contradiction.

Original entry on oeis.org

2, 4, 3, 6, 5, 8, 7, 12, 11, 14, 13, 18, 17, 20, 19, 24, 23, 30, 29, 32, 31, 38, 37, 42, 41, 44, 43, 48, 47, 54, 53, 60, 59, 62, 61, 68, 67, 72, 71, 74, 73, 80, 79, 84, 83, 90, 89, 98, 97, 102, 101, 104, 103, 108, 107, 110, 109, 114, 113, 128, 127, 132, 131, 138, 137, 140, 139, 150, 149
Offset: 1

Views

Author

Bernard Schott, Jun 09 2019

Keywords

Comments

The idea of this sequence comes from A282649 where "larger" replaces "smaller".
The sequence is not a permutation of the positive integers.
The 1st bisection is A000040 (the primes) and the 2nd bisection is A008864 \ {3} (prime(n) + 1).
Consecutive primes p < q separated by composites c = q + 1. - Michael De Vlieger, Jun 09 2019

Examples

			In the 1st pair of integers (2,4) the smaller term is (2), which is prime;
In the 2nd pair of integers (4,3) the smaller term is (3), which is prime;
In the 3rd pair of integers (3,6) the smaller term is (3), which is prime;
In the 4th pair of integers (6,5) the smaller term is (5), which is prime;
In the 5th pair of integers (5,8) the smaller term is (5), which is prime; etc.
		

Crossrefs

Cf. A000040 (prime numbers), A002808 (composite numbers), A008864 (prime(n) + 1).
Cf. A282649 (similar, with larger term).
Cf. A067747, A073846, A073898 (sequences with same start).

Programs

  • Mathematica
    Fold[Join[#1, {#2, NextPrime@ #2 + 1}] &, {#, NextPrime@ # + 1} &@ 2, Prime@ Range[2, 35]] (* Michael De Vlieger, Jun 09 2019 *)

Formula

n odd: a(n) = prime((n+1)/2) = A000040((n+1)/2).
n even: a(n) = a(n+1) + 1 = prime(n/2 + 1) + 1 = A008864(n/2 + 1).
Alternatively, if a(n-1) is prime, a(n) = 1 + min prime > a(n-1) else a(n) = a(n-1) - 1. - Bill McEachen, May 16 2024
Showing 1-2 of 2 results.