OFFSET
1,2
COMMENTS
Every composite number appears in this sequence. Eventually, every p^2 (p prime) will appear; if the smallest unused composite does not follow, it will appear no later than following the next p^2.
LINKS
T. D. Noe, Table of n, a(n) for n=1..1000
MAPLE
# Corrected Maple program from Chen Zekai, Mar 23 2015, added by N. J. A. Sloane, Mar 23 2015
A085084 := proc (q) local a, b, i, n; if q = 1 then print(1); return; elif q = 2 then print(1); print(4); return; fi; a := {1, 4}; b := 4; i := 2; print(1); print(4); while i < q do for n from 6 to q^2 doif not isprime(n) and gcd(b, n) = 1 and {} = a intersect {n} thenb := n; a := a union {n}; i := i+1; print(n); break; fi; od; od; end:A085084(10000):
MATHEMATICA
A085084 = {a[1]=1, a[2]=4}; a[n_] := a[n] = Catch[For[k = 6, True, k++, If[!PrimeQ[k] && !MemberQ[A085084, k] && CoprimeQ[a[n-1], k], AppendTo[A085084, k]; Throw[k]]]]; Table[ a[n], {n, 1, 68}] (* Jean-François Alcover, Jul 17 2012 *)
PROG
(Haskell)
import Data.List (find, delete)
import Data.Maybe (fromJust)
a085084 n = a085084_list !! (n-1)
a085084_list = 1 : f 1 a002808_list where
f x cs = y : f y (delete y cs) where
y = fromJust $ find ((== 1) . (gcd x)) cs
-- Reinhard Zumkeller, Dec 01 2012
CROSSREFS
KEYWORD
easy,nice,nonn
AUTHOR
Amarnath Murthy, Jul 02 2003
EXTENSIONS
Corrected and extended by Vladeta Jovovic, Jul 05 2003
Additional comments from Franklin T. Adams-Watters, Sep 19 2006
Edited by N. J. A. Sloane, Jul 03 2008 at the suggestion of R. J. Mathar
STATUS
approved