OFFSET
1,1
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
David L. Applegate, Hans Havermann, Bob Selcoe, Vladimir Shevelev, N. J. A. Sloane, and Reinhard Zumkeller, The Yellowstone Permutation, arXiv preprint arXiv:1501.01669 [math.NT], 2015 and J. Int. Seq. 18 (2015) 15.6.7.
MATHEMATICA
terms = 70; max = 2 terms;
f[lst_] := Block[{k = 4}, While[GCD[lst[[-2]], k] == 1 || GCD[lst[[-1]], k] > 1 || MemberQ[lst, k], k++]; Append[lst, k]];
A098550 = Nest[f, {1, 2, 3}, max-3];
sel = Select[Transpose[{Range[max], A098550}], PrimeQ[#[[2]]]&][[All, 1]]+2;
a[n_] := For[k = 1, k <= max, k = k+2, If[CompositeQ[k] && FreeQ[A098550[[1 ;; n]], k] && FreeQ[A251542, k], Return[k]]];
Table[a[n], {n, 1, terms}] (* Jean-François Alcover, Dec 06 2018, after Robert G. Wilson v in A098550 *)
PROG
(Haskell)
import Data.List (delete); import Data.List.Ordered (minus)
a251558 n = a251558_list !! (n-1)
a251558_list = 9 : 9 : 9 : f 2 3 [4..] (tail a014076_list) where
f u v ws zs = g ws where
g (x:xs) = if gcd x u > 1 && gcd x v == 1
then y : f v x (delete x ws) ys else g xs
where ys@(y:_) = zs `minus` [x]
-- Reinhard Zumkeller, Mar 11 2015
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Dec 23 2014
STATUS
approved