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 A347113 #94 Sep 05 2022 09:55:26 %S A347113 1,4,10,22,46,94,5,2,6,14,3,8,12,26,9,15,18,38,13,7,16,34,20,24,30,62, %T A347113 21,11,27,32,36,74,25,28,58,118,17,33,40,82,166,334,35,39,42,86,29,44, %U A347113 48,56,19,45,23,50,54,60,122,41,49,52,106,214,43,55,63,66 %N A347113 a(1)=1; for n > 1, a(n) is the smallest unused positive number k such that k != j and gcd(k,j) != 1, where j = a(n-1) + 1. %C A347113 Alternative definition: Lexicographically earliest sequence of distinct positive numbers such that a(n) != a(n-1)+1 and gcd(a(n-1)+1,a(n)) > 1. This makes it a cousin of the EKG sequence A064413, the Yellowstone permutation A098550, the Enots Wolley sequence A336957, and others. - _N. J. A. Sloane_, Sep 01 2021; revised Nov 08 2021. %C A347113 The successive gcd's are listed in A347309. %H A347113 Michel Marcus, <a href="/A347113/b347113.txt">Table of n, a(n) for n = 1..10000</a> %H A347113 Chai Wah Wu, <a href="/A347113/a347113.txt">Table of n, a(n) for n = 1..10^6</a> %H A347113 Chai Wah Wu, <a href="/A347113/a347113.png">Graph of first million terms</a> %H A347113 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the integers</a> %e A347113 a(1) = 1, by definition. %e A347113 a(2) = 4; it cannot be 2, because 2 = a(1) + 1, and it cannot be 3, because gcd(a(1) + 1, 3) = 1. %e A347113 a(3) = 10, because gcd(a(3), a(2) + 1) cannot equal 1. a(2) + 1 = 5, so a(3) must be a multiple of 5. It cannot be equal to 5, so it must be 10, the next available multiple of 5. %e A347113 a(4) = 22, because 22 is the smallest positive integer not equal to 11 and not coprime to 11. %p A347113 b:= proc() true end: %p A347113 a:= proc(n) option remember; local j, k; j:= a(n-1)+1; %p A347113 for k from 2 do if b(k) and k<>j and igcd(k, j)>1 %p A347113 then b(k):= false; return k fi od %p A347113 end: a(1):= 1: %p A347113 seq(a(n), n=1..100); # _Alois P. Heinz_, Sep 02 2021 %t A347113 Block[{a = {1}, c, k, m = 2}, Do[If[IntegerQ@Log2[i], While[IntegerQ[c[m]], m++]]; Set[k, m]; While[Or[IntegerQ[c[k]], k == # + 1, GCD[k, # + 1] == 1], k++] &[a[[-1]]]; AppendTo[a, k]; Set[c[k], i], {i, 65}]; a] (* _Michael De Vlieger_, Aug 18 2021 *) %o A347113 (PARI) find(va, x) = {my(k=1, s=Set(va)); while ((k==x) || (gcd(k, x) == 1) || setsearch(s, k), k++); k;} %o A347113 lista(nn) = {my(va = vector(nn)); va[1] = 1; for (n=2, nn, va[n] = find(va, va[n-1]+1);); va;} \\ _Michel Marcus_, Aug 21 2021 %o A347113 (Python) %o A347113 from math import gcd %o A347113 A347113_list, nset, m = [1], {1}, 2 %o A347113 for _ in range(100): %o A347113 j = A347113_list[-1]+1 %o A347113 k = m %o A347113 while k == j or gcd(k,j) == 1 or k in nset: %o A347113 k += 1 %o A347113 A347113_list.append(k) %o A347113 nset.add(k) %o A347113 while m in nset: %o A347113 m += 1 # _Chai Wah Wu_, Sep 01 2021 %Y A347113 See A347306 for the inverse, A347307, A347308 for the records, A347309 for the gcd values, A347312 for the parity of a(n), A347314 for the fixed points, and A348780 for partial sums. %Y A347113 For the main diagonal see (A348787(k), A348788(k)). %Y A347113 Cf. A064413, A098550, A336957, A347313, A348779, A348785, A348786, A353712, A353713. %K A347113 nonn %O A347113 1,2 %A A347113 _Grant Olson_, Aug 18 2021 %E A347113 Comments edited (including deletion of incorrect comments) by _N. J. A. Sloane_, Sep 05 2021 %E A347113 For the moment I am withdrawing my claim that this is a permutation of the positive integers. - _N. J. A. Sloane_, Sep 05 2022