%I #56 May 13 2022 05:14:56
%S 1,2,3,5,7,4,9,11,13,8,15,17,19,14,23,25,27,16,29,31,21,10,37,41,33,
%T 20,43,47,39,22,35,53,51,26,49,55,57,32,59,61,45,28,67,71,65,6,73,77,
%U 79,12,83,85,89,18,91,95,97,24,101,103,107,30,109,113,119,36,115,121,127,34
%N a(1)=1, a(2)=2, a(3)=3, a(n) = smallest positive integer not occurring earlier in sequence and coprime to a(n-1), a(n-2) and a(n-3).
%C Conjectured to be not a permutation of the natural numbers.
%C _Charles R Greathouse IV_ extended this, and confirms that primes occur in natural order. - _Jonathan Vos Post_ and _M. F. Hasler_, Jan 18 2011
%C Conjecture: for n >= 67, a(n) is even if and only if n == 2 (mod 4) and divisible by 3 if and only if n == 3 (mod 4). In particular, this implies the last value divisible by 6 is a(66) = 36. - _Robert Israel_, May 12 2015
%C a(102982) = 42, see A105214. Conjecture above is false. - _Sergio Pimentel_, Apr 18 2022
%H Alois P. Heinz, <a href="/A103683/b103683.txt">Table of n, a(n) for n = 1..10000</a>
%p ina:= proc(n) false end:
%p a:= proc(n) option remember; local k;
%p if n<4 then k:= n
%p else for k from 4 while ina(k) or igcd(k, a(n-1))<>1 or
%p igcd(k, a(n-2))<>1 or igcd(k, a(n-3))<>1
%p do od
%p fi; ina(k):= true; k
%p end:
%p seq(a(n), n=1..120); # _Alois P. Heinz_, Jan 19 2011
%t f[s_] := Block[{k = 1, l = Take[s, -3]}, While[ Union[ GCD[k, l]] != {1} || MemberQ[s, k], k++]; Append[s, k]]; Nest[f, {1, 2, 3}, 70] (* _Robert G. Wilson v_, Jun 26 2011 *)
%o (Python)
%o from math import gcd
%o from itertools import islice
%o def agen(): # generator of terms
%o aset, b, c, d = {1, 2, 3, 5}, 2, 3, 5
%o yield from [1, b, c, d]
%o while True:
%o k = 1
%o while k in aset or any(gcd(t, k) != 1 for t in [b, c, d]): k+= 1
%o b, c, d = c, d, k
%o aset.add(k)
%o yield k
%o print(list(islice(agen(), 70))) # _Michael S. Branicky_, Apr 18 2022
%Y Cf. A084937, A105214, A352950.
%K nonn
%O 1,2
%A _Leroy Quet_, Mar 26 2005
%E More terms from _Robert G. Wilson v_, Mar 30 2005
|