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”).

A103864
a(1) = 1; a(n) = smallest positive integer not occurring earlier in sequence if n is a prime. a(n) = a(n-1)th smallest positive integer among those not occurring earlier in sequence if n is composite.
4
1, 2, 3, 6, 4, 9, 5, 12, 20, 29, 7, 16, 8, 19, 33, 48, 10, 24, 11, 27, 46, 67, 13, 32, 55, 80, 106, 133, 14, 36, 15, 39, 68, 99, 132, 167, 17, 43, 75, 111, 18, 47, 21, 53, 91, 135, 22, 57, 98, 146, 196, 247, 23, 60, 105, 157, 212, 269, 25, 64, 26, 69, 121, 180, 242, 307, 28
OFFSET
1,2
COMMENTS
Sequence is a permutation of the positive integers.
EXAMPLE
Since 6 is composite, a(6) = a(5)th (4th) smallest positive integer not occurring earlier in sequence. The terms not occurring earlier in sequence are 5,7,8,9,10... and the 4th of these is 9.
MATHEMATICA
a = {1}; Do[AppendTo[a, Complement[Range[Max[a] + a[[-1]] + 1], a][[If[PrimeQ[n], 1, a[[-1]]]]]], {n, 2, 67}]; a (* Ivan Neretin, May 09 2015 *)
CROSSREFS
Inverse: A103866.
Cf. A103865, A103867 (variant and its inverse).
Sequence in context: A084980 A101369 A125147 * A268712 A152679 A232561
KEYWORD
nonn,look
AUTHOR
Leroy Quet, Feb 18 2005
EXTENSIONS
More terms from John W. Layman, May 27 2005
Corrected by Franklin T. Adams-Watters, Nov 22 2006
STATUS
approved