Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #35 Oct 27 2023 21:59:55
%S 1,2,3,4,5,6,12,18,9,27,36,24,8,16,32,40,10,20,30,15,45,54,42,7,14,21,
%T 28,35,49,56,48,60,50,25,75,90,63,70,77,11,22,33,44,55,66,72,64,80,88,
%U 96,78,13,26,39,52,65,91,84,98,105
%N a(n) = n for n <= 6; for n > 6, a(n) is the smallest number not already used such that gcd(a(n), a(n-1)) >= 6.
%C A permutation of the natural numbers.
%H Alois P. Heinz, <a href="/A177958/b177958.txt">Table of n, a(n) for n = 1..10000</a> (first 2000 terms from Ivan Neretin)
%H J. C. Lagarias, E. M. Rains and N. J. A. Sloane, <a href="http://www.emis.de/journals/EM/expmath/volumes/11/11.3/Lagarias437_446.pdf">The EKG sequence</a>, Exper. Math. 11 (2002), 437-446.
%H J. C. Lagarias, E. M. Rains and N. J. A. Sloane, <a href="http://arxiv.org/abs/math/0204011">The EKG sequence</a>, arXiv:math/0204011 [math.NT], 2002.
%H <a href="/index/Ed#EKG">Index entries for sequences related to EKG sequence</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%p ina:= proc(n) evalb(n<7) end:
%p a:= proc(n) option remember;
%p local k;
%p if n<7 then n
%p else for k while ina(k) or igcd (k, a(n-1))<6 do od;
%p ina(k):= true; k
%p fi
%p end;
%p seq(a(n), n=1..60);
%t t=Range[6]; Do[k=7; While[MemberQ[t, k] || GCD[t[[-1]], k] < 6, k++]; AppendTo[t, k], {n, 7, 100}]; t
%o (Python)
%o from sympy import gcd
%o l=list(range(1, 7))
%o for n in range(6, 101):
%o k=7
%o while k in l or gcd(l[n - 1], k)<6: k+=1
%o l.append(k)
%o print(l) # _Indranil Ghosh_, Jun 27 2017
%Y Cf. A064413, A064417, A064418, A064419, A262434 (inverse).
%K nonn,easy
%O 1,2
%A _Jonathan Vos Post_, Dec 16 2010
%E Edited by _Alois P. Heinz_, Dec 16 2010