OFFSET
1,2
COMMENTS
A permutation of the natural numbers.
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, arXiv:math/0204011 [math.NT], 2002; Exper. Math. 11 (2002), 437-446.
J. C. Lagarias, E. M. Rains and N. J. A. Sloane, Problem 10927, Amer. Math. Monthly, 109 (2002), 202; The EKG Sequence: 10927, 111 (No. 2, 2004), 167-168.
MATHEMATICA
a[n_ /; n <= 3] := n; a[n_] := a[n] = For[aa = Array[a, n-1] // Sort; k = If[n == 4, 4, Complement[Range[aa // Last], aa] // First]; aa = Drop[aa, k-1], True, k++, If[FreeQ[aa, k], If[GCD[k, a[n-1]] >= 3, Return[k]]]]; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Jan 28 2015 *)
PROG
(Haskell)
import Data.List (delete)
a064417 n = a064417_list !! (n-1)
a064417_list = 1 : 2 : 3 : f 3 [4..] where
f x us = x' : f x' (delete x' us) where
x' = head [u | u <- us, gcd u x > 2]
-- Reinhard Zumkeller, Nov 13 2011
CROSSREFS
KEYWORD
nonn,nice,easy
AUTHOR
Jonathan Ayres (Jonathan.ayres(AT)btinternet.com), Sep 30 2001
EXTENSIONS
More terms from Naohiro Nomoto, Sep 30 2001
STATUS
approved