%I #54 Sep 26 2018 03:30:57
%S 1,2,3,4,6,8,9,10,12,5,14,15,7,18,21,16,27,20,33,24,11,26,22,13,28,39,
%T 32,30,34,25,17,35,51,40,42,38,36,19,44,57,46,45,23,48,69,50,54,52,58,
%U 56,29,49,87,63,60,77,62,55,31,65,93,70,66,64,74,68,37
%N a(n)=n when n <= 3, otherwise a(n) is the smallest positive number not yet in the sequence such that gcd(a(n), a(n-1)) <= gcd(a(n), a(n-2)) > 1.
%C This is a permutation of the natural numbers: the proof for A098550 applies with essentially no changes. [Confirmed by _N. J. A. Sloane_, Feb 27 2015]
%C For n > 3, all primes first appear in order as composites with one smaller prime (proof similar to that in A098550).
%C For any given set S of primes, the subsequence consisting of numbers whose prime factors are exactly the primes in S appears in increasing order. For example, if S = {2,3}, 6 appears first, followed by 12, 18, 24, 36, 48, 54, 72, etc.
%C Appears to be very similar to A064413. Compare the respective inverses A255479 and A064664; see also A255482. Speaking very loosely, the ratio a(n)/n seems to be about 1/2, 1, or 3/2, just as for A064413, although this is a long way from being proved for either sequence. _David Applegate_ points out that this is (presumably) because primes p >= 13 always occur as part of a subsequence 2p X p Y 3p, and subsequences 2p X p Y 5p, 2p X p Y 7p, etc. that produced the extra curves in the graph of A098550 just do not happen. - _N. J. A. Sloane_, Feb 27 2015, Mar 05 2015.
%C First differs from A254077 at a(29). - _Omar E. Pol_, May 21 2015
%H Hiroaki Yamanouchi, <a href="/A255582/b255582.txt">Table of n, a(n) for n = 1..10000</a>
%H David L. Applegate, Hans Havermann, Bob Selcoe, Vladimir Shevelev, N. J. A. Sloane, and Reinhard Zumkeller, <a href="http://arxiv.org/abs/1501.01669">The Yellowstone Permutation</a>, arXiv preprint arXiv:1501.01669, 2015.
%t a[n_] := a[n] = If[n<5, n, For[k=5, True, k++, If[FreeQ[Array[a, n-1], k], If[GCD[k, a[n-2]]>1 && GCD[k, a[n-1]] <= GCD[k, a[n-2]], Return[k]]]]];
%t Array[a, 100] (* _Jean-François Alcover_, Jul 31 2018 *)
%o (Haskell)
%o import Data.List (delete)
%o a255582 n = a255582_list !! (n-1)
%o a255582_list = 1 : 2 : 3 : f 2 3 [4..] where
%o f u v ws = y : f v y (delete y ws) where
%o y = head [z | z <- ws, let d = gcd u z, d > 1, gcd v z <= d]
%o -- _Reinhard Zumkeller_, Mar 10 2015
%Y Cf. A098550, A254077, A064413, A064664, A255480, A255481, A255482, A256974.
%Y A255479 is the inverse permutation.
%Y A256424 is a smoothed version.
%Y A256529 gives the partial sums.
%K nonn,hear
%O 1,2
%A _Bob Selcoe_, Feb 26 2015
%E a(41)-a(67) from _Hiroaki Yamanouchi_, Feb 27 2015