login
A196189
Smallest number not yet in the sequence greater than n+1 and relatively prime to n.
3
3, 5, 7, 9, 8, 11, 10, 13, 14, 17, 15, 19, 16, 23, 22, 21, 20, 25, 24, 27, 26, 29, 28, 31, 32, 33, 34, 37, 35, 41, 36, 39, 38, 43, 44, 47, 40, 45, 46, 49, 48, 53, 50, 51, 52, 55, 54, 59, 57, 61, 56, 63, 58, 65, 62, 67, 64, 69, 66, 71, 68, 73, 74, 75, 72, 79, 70, 77, 76
OFFSET
1,1
LINKS
Franklin T. Adams-Watters, Table of n, a(n) for n = 1..10000
PROG
(PARI) invecn(v, n, x)=for(k=1, n, if(v[k]==x, return(k))); 0
nexta(v, n)=local(k=n+2); while(gcd(k, n)>1||invecn(v, n-1, k), k++); k
al(n)=local(v=vector(n)); for(k=1, n, v[k]=nexta(v, k)); v
(Haskell)
a196189 n = a196189_list !! (n-1)
a196189_list = f 1 [] where
f n xs = x : f (n+1) (x:xs) where
x = head [z | z <- [n+2..], z `notElem` xs, gcd z n == 1]
-- Reinhard Zumkeller, Sep 29 2011
CROSSREFS
Cf. A169190, A065190 (if condition a(n) > n dropped).
Sequence in context: A139083 A252002 A139081 * A206543 A274988 A265509
KEYWORD
nonn
AUTHOR
STATUS
approved