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.

This page as a plain text file.
%I A355212 #14 Sep 03 2024 15:03:45
%S A355212 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,
%T A355212 19,57,21,24,22,46,23,115,25,30,26,36,27,42,28,58,29,899,31,62,32,74,
%U A355212 37,148,38,40,82,41,1763,43,86,44,48,45,141,47,329,49,56,50
%N A355212 A variant of the EKG sequence (A064413) where the least value not yet in the sequence appears as soon as possible.
%C A355212 To build the sequence:
%C A355212 - we start with a(1) = 1 and a(2) = 2, and then repeatedly:
%C A355212 - let a(n) be the last known term and v the least value not yet in the sequence,
%C A355212 - if gcd(a(n), v) > 1
%C A355212   then a(n+1) = v,
%C A355212 - otherwise:
%C A355212   - let w be the least value not yet in the sequence such that gcd(a(n), w) > 1
%C A355212     and gcd(w, v) > 1,
%C A355212   - then a(n+1) = w and a(n+2) = v.
%C A355212 This sequence is a permutation of the positive integers with inverse A355213.
%C A355212 The construction is similar to that of A352713.
%H A355212 Rémy Sigrist, <a href="/A355212/b355212.txt">Table of n, a(n) for n = 1..10000</a>
%H A355212 Rémy Sigrist, <a href="/A355212/a355212.gp.txt">PARI program</a>
%H A355212 <a href="/index/Ed#EKG">Index entries for sequences related to EKG sequence</a>
%H A355212 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%e A355212 The first terms are (stars correspond to "w" terms):
%e A355212   n   a(n)  w
%e A355212   --  ----  -
%e A355212    1     1
%e A355212    2     2
%e A355212    3     6  *
%e A355212    4     3
%e A355212    5    12  *
%e A355212    6     4
%e A355212    7    10  *
%e A355212    8     5
%e A355212    9    35  *
%e A355212   10     7
%e A355212   11    14  *
%e A355212   12     8
%e A355212   13    18  *
%e A355212   14     9
%e A355212   15    33  *
%e A355212   16    11
%o A355212 (PARI) \\ See Links section.
%o A355212 (Python)
%o A355212 from math import gcd
%o A355212 from itertools import count, islice
%o A355212 def agen(): # generator of terms
%o A355212     aset, an, v = {1, 2}, 2, 3; yield from [1, 2]
%o A355212     for n in count(3):
%o A355212         if gcd(an, v) == 1:
%o A355212             w = v + 1
%o A355212             while w in aset or gcd(an, w) == 1 or gcd(w, v) == 1: w += 1
%o A355212             aset.add(w); yield w
%o A355212         an = v; aset.add(an); yield an
%o A355212         while v in aset: v += 1
%o A355212 print(list(islice(agen(), 65))) # _Michael S. Branicky_, Jun 24 2022
%Y A355212 Cf. A064413, A352713, A355213 (inverse).
%K A355212 nonn
%O A355212 1,2
%A A355212 _Rémy Sigrist_, Jun 24 2022