OFFSET
1,2
EXAMPLE
The smallest integer that is greater than a(20)=29 and is coprime to 28 (the largest nonprime which occurs among the first 20 terms of the sequence) is 31. So a(21) = 31.
MAPLE
A122090 := proc(maxn) local a, nexta, n, lanopr; a := [1]; lanopr := 1; for n from 2 to maxn do nexta := op(n-1, a)+1; while gcd(nexta, lanopr) >1 do nexta := nexta+1; od; a := [op(a), nexta]; if not isprime(nexta) and nexta > lanopr then lanopr := nexta; fi; od; RETURN(a); end: maxn := 100 : alist := A122090(maxn) : for i from 1 to maxn do printf("%d, ", op(i, alist)); end : # R. J. Mathar, Oct 21 2006
MATHEMATICA
f[l_List] := Block[{k = Last[l] + 1, m = Max[Select[l, ! PrimeQ[ # ] &]]}, While[GCD[k, m] > 1, k++ ]; Append[l, k]]; Nest[f, {1}, 70] (* Ray Chandler, Oct 19 2006 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Oct 17 2006
EXTENSIONS
Extended by Ray Chandler, Oct 19 2006
More terms from R. J. Mathar, Oct 21 2006
STATUS
approved