cp's OEIS Frontend

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.

A251622 a(1) = 1; a(2) = 2; for n > 2, a(n) = smallest number not already used which shares a factor with a(n-1) or a(n-2).

This page as a plain text file.
%I A251622 #19 Sep 05 2018 15:42:24
%S A251622 1,2,4,6,3,8,9,10,5,12,14,7,16,18,15,20,21,22,11,24,26,13,28,30,25,27,
%T A251622 33,36,32,34,17,38,19,40,35,42,39,44,45,46,23,48,50,51,52,54,56,49,58,
%U A251622 29,60,55,57,63,66,62,31,64,68,70,65,72,69,74,37,76,78,75,80
%N A251622 a(1) = 1; a(2) = 2; for n > 2, a(n) = smallest number not already used which shares a factor with a(n-1) or a(n-2).
%C A251622 This appears certainly to be a permutation of the positive integers.
%C A251622 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
%C A251622 For n > 2: gcd(a(n),a(n-1)*a(n-2)) > 1. - _Reinhard Zumkeller_, Apr 05 2015
%H A251622 Reinhard Zumkeller, <a href="/A251622/b251622.txt">Table of n, a(n) for n = 1..10000</a>
%H A251622 J. C. Lagarias, E. M. Rains and N. J. A. Sloane, <a href="http://arXiv.org/abs/math.NT/0204011">The EKG sequence</a>, Exper. Math. 11 (2002), 437-446.
%H A251622 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>
%t A251622 a[1] = 1; a[2] = 2;
%t A251622 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]]]];
%t A251622 Array[a, 100] (* _Jean-François Alcover_, Sep 05 2018 *)
%o A251622 (PARI) invecn(v,k,x)=for(i=1,k,if(v[i]==x,return(i)));0
%o A251622 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
%o A251622 (Haskell)
%o A251622 a251622 n = a251622_list !! (n-1)
%o A251622 a251622_list = 1 : 2 : f 1 2 [3..] where
%o A251622    f u v xs = g xs where
%o A251622      g (w:ws) = if gcd w u > 1 || gcd w v > 1
%o A251622                    then w : f v w (delete w xs) else g ws
%o A251622 -- _Reinhard Zumkeller_, Apr 05 2015
%Y A251622 Cf. A064413, A089088, A098550.
%Y A251622 Cf. A256628 (conjectured inverse).
%K A251622 nonn
%O A251622 1,2
%A A251622 _Franklin T. Adams-Watters_, Dec 06 2014