login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A163463
a(1)=1. For n >= 2: If a(n-1) is coprime to n, then a(n) = the smallest integer > a(n-1) that is coprime to n. If a(n-1) is not coprime to n, then a(n) = the smallest integer > a(n-1) that is not coprime to n.
1
1, 3, 6, 8, 9, 10, 11, 13, 14, 15, 16, 18, 19, 23, 26, 28, 29, 31, 32, 34, 37, 39, 40, 42, 43, 45, 48, 49, 50, 51, 52, 54, 55, 57, 58, 60, 61, 63, 65, 66, 67, 71, 72, 74, 76, 78, 79, 83, 85, 86, 88, 90, 91, 95, 99, 101, 103, 105, 106, 108, 109, 111, 112, 114, 116, 117, 118
OFFSET
1,2
LINKS
MATHEMATICA
a = {1}; Do[If[GCD[n, a[[ -1]]] == 1, k = a[[ -1]] + 1; While[GCD[k, n] > 1, k++ ]; AppendTo[a, k], k = a[[ -1]] + 1; While[GCD[k, n] < 2, k++ ]; AppendTo[a, k]], {n, 2, 100}]; a (* Stefan Steinerberger, Aug 05 2009 *)
PROG
(PARI) al(n)=local(v, q); v=vector(n); v[1]=1; for(k=2, n, q=gcd(k, v[k-1])!=1; v[k]=v[k-1]+1; while(gcd(k, v[k])!=1!=q, v[k]++)); v \\ Franklin T. Adams-Watters, Aug 06 2009
CROSSREFS
Sequence in context: A350618 A133159 A188544 * A137386 A358510 A344952
KEYWORD
nonn
AUTHOR
Leroy Quet, Jul 28 2009
EXTENSIONS
More terms from Stefan Steinerberger and Franklin T. Adams-Watters, Aug 05 2009
STATUS
approved