OFFSET
1,2
COMMENTS
This appears certainly to be a permutation of the positive integers.
I believe the arguments we used to show that the EKG sequence (A064413) is a permutation of the natural numbers apply here with almost no change. - N. J. A. Sloane, Jan 02 2015
For n > 2: gcd(a(n),a(n-1)*a(n-2)) > 1. - Reinhard Zumkeller, Apr 05 2015
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
J. C. Lagarias, E. M. Rains and N. J. A. Sloane, The EKG sequence, Exper. Math. 11 (2002), 437-446.
J. C. Lagarias, E. M. Rains and N. J. A. Sloane, The EKG Sequence
MATHEMATICA
a[1] = 1; a[2] = 2;
a[n_] := a[n] = For[k = 1, True, k++, If[FreeQ[Array[a, n-1], k], If[!CoprimeQ[k, a[n-1]] || !CoprimeQ[k, a[n-2]], Return[k]]]];
Array[a, 100] (* Jean-François Alcover, Sep 05 2018 *)
PROG
(PARI) invecn(v, k, x)=for(i=1, k, if(v[i]==x, return(i))); 0
alist(n)=local(v=vector(n), x); v[1]=1; v[2]=2; for(k=3, n, x=3; while(invecn(v, k-1, x)||(gcd(v[k-1], x)==1&&gcd(v[k-2], x)==1), x++); v[k]=x); v
(Haskell)
a251622 n = a251622_list !! (n-1)
a251622_list = 1 : 2 : f 1 2 [3..] where
f u v xs = g xs where
g (w:ws) = if gcd w u > 1 || gcd w v > 1
then w : f v w (delete w xs) else g ws
-- Reinhard Zumkeller, Apr 05 2015
CROSSREFS
KEYWORD
nonn
AUTHOR
Franklin T. Adams-Watters, Dec 06 2014
STATUS
approved