A255582 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.
Links
- Hiroaki Yamanouchi, 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, 2015.
Crossrefs
Programs
-
Haskell
import Data.List (delete) a255582 n = a255582_list !! (n-1) a255582_list = 1 : 2 : 3 : f 2 3 [4..] where f u v ws = y : f v y (delete y ws) where y = head [z | z <- ws, let d = gcd u z, d > 1, gcd v z <= d] -- Reinhard Zumkeller, Mar 10 2015
-
Mathematica
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]]]]]; Array[a, 100] (* Jean-François Alcover, Jul 31 2018 *)
Comments