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 A384045 #13 May 27 2025 10:34:43 %S A384045 1,2,4,3,6,5,10,7,14,9,8,12,11,22,13,26,15,18,17,16,20,19,38,21,24,23, %T A384045 46,25,30,29,27,33,28,32,31,62,35,34,36,39,37,74,41,40,42,44,43,86,45, %U A384045 48,47,94,49,56,51,50,52,54,53,106,55,60,59,57,63,58,64,61 %N A384045 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 it is greater than it, else it is coprime to a(n-1) if it is less than it. %C A384045 For the terms studied all primes appear in their natural order, and approximately 65% of all primes p are immediately followed by a term 2*p. These later terms form the upper of the two lines in the graph. %C A384045 In the first 100000 terms the fixed points are 1, 2, 12, 18, 98, 182, 306, 380; it is likely no more exist. %C A384045 The sequence is a permutation of the positive integers as the lowest unused number after k terms will always appear as it will eventually be coprime to a(j) for some j > k. %H A384045 Scott R. Shannon, <a href="/A384045/b384045.txt">Table of n, a(n) for n = 1..10000</a> %e A384045 a(3) = 4 as a(2) = 2 and 4 > 2 and shares a factor with it. Note 3 cannot be chosen as 3 > 2 but is coprime to 2. %e A384045 a(4) = 3 as a(3) = 4 and 3 < 4 and is coprime to it. %t A384045 nn = 120; c[_] := False; j = 2; u = 3; c[1] = c[2] = True; %t A384045 {1, 2}~Join~Reap[Do[k = u; %t A384045 While[And[k < j, Or[c[k], ! CoprimeQ[j, k]]], k++]; %t A384045 If[k >= j, %t A384045 If[PrimePowerQ[j], %t A384045 Set[{p, k}, {FactorInteger[j][[1, 1]], 1}]; While[c[k*p], k++]; k *= p, %t A384045 While[Or[c[k], CoprimeQ[j, k]], k++] ] ]; %t A384045 Sow[k]; Set[{c[k], j}, {True, k}]; %t A384045 If[k == u, While[c[u], u++]], %t A384045 {n, 3, nn}] ][[-1, 1]] (* _Michael De Vlieger_, May 27 2025 *) %Y A384045 Cf. A375563, A375564, A373545, A373546, A064413. %K A384045 nonn %O A384045 1,2 %A A384045 _Scott R. Shannon_, May 18 2025