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

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

%I #22 Feb 14 2016 14:56:12

%S 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,

%T 106,133,14,36,15,39,68,99,132,167,17,43,75,111,18,47,21,53,91,135,22,

%U 57,98,146,196,247,23,60,105,157,212,269,25,64,26,69,121,180,242,307,28

%N 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.

%C Sequence is a permutation of the positive integers.

%H Ivan Neretin, <a href="/A103864/b103864.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%e 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.

%t 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 *)

%Y Inverse: A103866.

%Y Cf. A103865, A103867 (variant and its inverse).

%K nonn,look

%O 1,2

%A _Leroy Quet_, Feb 18 2005

%E More terms from _John W. Layman_, May 27 2005

%E Corrected by _Franklin T. Adams-Watters_, Nov 22 2006