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.
%I A373546 #11 Jun 12 2024 17:34:18 %S A373546 1,2,4,6,3,5,7,8,10,12,9,11,13,14,16,18,15,17,19,20,22,24,21,23,25,26, %T A373546 28,30,27,29,31,32,34,36,33,35,37,38,40,42,39,41,43,44,46,48,45,47,49, %U A373546 50,52,54,51,53,55,56,58,60,57,59,61,62,64,66,63,65,67,68,70,72,69,71,73,74,76,78,75 %N A373546 a(1) = 1, a(2) = 2; for n > 2, a(n) is the smallest unused positive number that shares a factor with a(n-1) if a(n-1) is even otherwise is coprime to a(n-1) if a(n-1) is odd. %C A373546 The sequence forms a repetitive pattern of three even numbers separated by 2 followed by three odd numbers separated by 2, the first odd number being 3 less than the third even number. One third of all terms are fixed points, and the primes appear in their natural order. %C A373546 First differences repeat {1, 2, 2, -3, 2, 2}. - _Michael De Vlieger_, Jun 11 2024 %H A373546 Michael De Vlieger, <a href="/A373546/b373546.txt">Table of n, a(n) for n = 1..10000</a> %H A373546 Michael De Vlieger, <a href="/A373546/a373546.png">Labeled scatterplot of a(n)</a> n = 1..72, with red indicating prime, gold indicating odd, and dark blue indicating even terms. %e A373546 a(9) = 10 as a(8) = 8 is an even number and 10 is the smallest unused positive number to share a factor with 8. %t A373546 kk = 2; nn = 120; c[_] := False; Array[Set[{a[#], c[#]}, {#, True}] &, kk]; %t A373546 j = a[kk]; u = kk + 1; %t A373546 Do[If[EvenQ[j], %t A373546 If[PrimePowerQ[j], %t A373546 p = FactorInteger[j][[1, 1]]; %t A373546 k = #1 + Boole[#2 > 0] & @@ QuotientRemainder[u, p]; %t A373546 While[c[k p], k++]; k *= p, %t A373546 k = u; While[Or[c[k], CoprimeQ[j, k]], k++]], %t A373546 k = u; While[Or[c[k], ! CoprimeQ[j, k]], k++] ]; %t A373546 Set[{a[n], c[k], j}, {k, True, k}]; %t A373546 If[k == u, While[c[u], u++]], {n, kk + 1, nn}]; %t A373546 Array[a, nn] (* _Michael De Vlieger_, Jun 11 2024 *) %Y A373546 Cf. A373545, A064413, A005843, A005408. %K A373546 nonn %O A373546 1,2 %A A373546 _Scott R. Shannon_, Jun 09 2024