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.

A373902 a(1) = 2; for n > 1, a(n) is the smallest positive number that does not equal a(n-1), shares a factor with a(n-1), and has not appeared as an adjacent term to a(n-1) previously in the sequence.

This page as a plain text file.
%I A373902 #20 Jun 22 2024 14:17:35
%S A373902 2,4,6,2,8,4,10,2,12,3,6,8,10,5,15,3,9,6,10,12,4,14,2,16,4,18,2,20,4,
%T A373902 22,2,24,3,18,6,12,8,14,6,15,9,12,14,7,21,3,27,6,16,8,18,9,21,6,20,5,
%U A373902 25,10,14,16,10,15,12,16,18,10,20,8,22,6,24,4,26,2,28,4,30,2,32,4,34,2,36,3
%N A373902 a(1) = 2; for n > 1, a(n) is the smallest positive number that does not equal a(n-1),  shares a factor with a(n-1), and has not appeared as an adjacent term to a(n-1) previously in the sequence.
%C A373902 See A371618 for the indices where the primes first appear.
%H A373902 Scott R. Shannon, <a href="/A373902/b373902.txt">Table of n, a(n) for n = 1..10000</a>
%H A373902 Scott R. Shannon, <a href="/A373902/a373902_2.png">Image of the first 250000 terms</a>. Prime terms are shown in red.
%e A373902 a(7) = 10 as a(6) = 4 and, although 2 and 6 share factors with 4, 2 and 4 form a previous adjacent pair, as do 4 and 6. This leaves 10 as the smallest number that shares a factor with 4 while 4 and 10 have not previously appeared as adjacent terms.
%t A373902 nn = 120; c[_] := {}; a[1] = j = 2; c[2] = {2};
%t A373902 Do[If[PrimePowerQ[j],
%t A373902   (k = 1;
%t A373902      While[Or[j == #  k, CoprimeQ[j, #  k], ! FreeQ[c[j], #  k]], k++];
%t A373902      k *= #) &[FactorInteger[j][[1, 1]]],
%t A373902    k = FactorInteger[j][[1, 1]];
%t A373902      While[Or[j == k, CoprimeQ[j, k], ! FreeQ[c[j], k]], k++] ];
%t A373902   Set[{a[n], c[j], c[k], j},
%t A373902       {k, Union[c[j], {k}], Union[c[k], {j}], k}], {n, 2, nn}];
%t A373902 Array[a, nn] (* _Michael De Vlieger_, Jun 22 2024 *)
%o A373902 (Python)
%o A373902 from math import gcd
%o A373902 from itertools import count, islice
%o A373902 def agen(): # generator of terms
%o A373902     an, adjacent = 2, {2: set()}
%o A373902     while True:
%o A373902         yield an
%o A373902         A = adjacent[an]
%o A373902         m = next(k for k in count(2) if k!=an and gcd(k, an)>1 and k not in A)
%o A373902         adjacent[an].add(m)
%o A373902         if m not in adjacent: adjacent[m] = set()
%o A373902         adjacent[m].add(an)
%o A373902         an = m
%o A373902 print(list(islice(agen(), 84))) # _Michael S. Branicky_, Jun 22 2024
%Y A373902 Cf. A371618, A064413, A027748, A364027.
%K A373902 nonn,look
%O A373902 1,1
%A A373902 _Scott R. Shannon_, Jun 22 2024