login
A122090
a(1)=1. a(n) = smallest integer that is greater than a(n-1) and is coprime to the largest nonprime (1 or composite) occurring among the first (n-1) terms of the sequence.
1
1, 2, 3, 4, 5, 7, 9, 10, 11, 13, 17, 19, 21, 22, 23, 25, 26, 27, 28, 29, 31, 33, 34, 35, 36, 37, 41, 43, 47, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 61, 63, 64, 65, 66, 67, 71, 73, 79, 83, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 101, 103, 107, 109, 113, 115, 116, 117
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
Sequence in context: A228894 A325367 A160718 * A066050 A004050 A123538
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