%I #17 Sep 15 2021 00:27:12
%S 1,2,4,3,7,5,11,6,8,9,19,10,22,12,13,14,30,15,33,16,17,18,40,20,21,23,
%T 24,25,53,26,56,27,28,29,31,32,68,34,35,36,76,37,79,38,39,41,87,42,43,
%U 44,45,46,98,47,48,49,50,51,109,52,112,54,55,57,58,59,125,60,61,62,132
%N a(1) = 1; a(n) is the smallest positive integer not occurring earlier in the sequence if n is a composite. a(n) = a(n-1)th smallest positive integer among those not occurring earlier in the sequence if n is prime.
%C Sequence is a permutation of the positive integers.
%H Michael De Vlieger, <a href="/A103865/b103865.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 5 is prime, a(5) = a(4)th (3rd) smallest positive integer not occurring earlier in the sequence. The terms not occurring earlier in the sequence are 5,6,7,8,9,... and the 3rd of these is 7.
%t Block[{a = {1}, nn = 71, s}, s = Range[2, 2 nn + 1]; Do[{AppendTo[a, First@ #1], Set[s, #2]} & @@ TakeDrop[s, If[CompositeQ@ i, 1, {a[[i - 1]]}]], {i, 2, nn}]; a] (* _Michael De Vlieger_, Sep 25 2017 *)
%Y Cf. A103864, A103866, A103867.
%K nonn
%O 1,2
%A _Leroy Quet_, Feb 18 2005
%E More terms from _Franklin T. Adams-Watters_, Nov 22 2006