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.

A355212 A variant of the EKG sequence (A064413) where the least value not yet in the sequence appears as soon as possible.

Original entry on oeis.org

1, 2, 6, 3, 12, 4, 10, 5, 35, 7, 14, 8, 18, 9, 33, 11, 143, 13, 39, 15, 20, 16, 34, 17, 323, 19, 57, 21, 24, 22, 46, 23, 115, 25, 30, 26, 36, 27, 42, 28, 58, 29, 899, 31, 62, 32, 74, 37, 148, 38, 40, 82, 41, 1763, 43, 86, 44, 48, 45, 141, 47, 329, 49, 56, 50
Offset: 1

Views

Author

Rémy Sigrist, Jun 24 2022

Keywords

Comments

To build the sequence:
- we start with a(1) = 1 and a(2) = 2, and then repeatedly:
- let a(n) be the last known term and v the least value not yet in the sequence,
- if gcd(a(n), v) > 1
then a(n+1) = v,
- otherwise:
- let w be the least value not yet in the sequence such that gcd(a(n), w) > 1
and gcd(w, v) > 1,
- then a(n+1) = w and a(n+2) = v.
This sequence is a permutation of the positive integers with inverse A355213.
The construction is similar to that of A352713.

Examples

			The first terms are (stars correspond to "w" terms):
  n   a(n)  w
  --  ----  -
   1     1
   2     2
   3     6  *
   4     3
   5    12  *
   6     4
   7    10  *
   8     5
   9    35  *
  10     7
  11    14  *
  12     8
  13    18  *
  14     9
  15    33  *
  16    11
		

Crossrefs

Cf. A064413, A352713, A355213 (inverse).

Programs

  • PARI
    \\ See Links section.
    
  • Python
    from math import gcd
    from itertools import count, islice
    def agen(): # generator of terms
        aset, an, v = {1, 2}, 2, 3; yield from [1, 2]
        for n in count(3):
            if gcd(an, v) == 1:
                w = v + 1
                while w in aset or gcd(an, w) == 1 or gcd(w, v) == 1: w += 1
                aset.add(w); yield w
            an = v; aset.add(an); yield an
            while v in aset: v += 1
    print(list(islice(agen(), 65))) # Michael S. Branicky, Jun 24 2022