%I #14 May 14 2024 02:24:55
%S 1,2,3,5,4,7,9,6,10,12,14,16,8,13,17,19,11,18,21,23,25,27,29,15,22,26,
%T 30,32,34,36,38,40,20,28,33,37,41,43,24,35,42,45,47,49,51,53,55,57,31,
%U 44,48,52,56,59,61,63,65,67,69,71,39,50,58,62,66,70,73,75,77,79,81,83
%N a(1)=1. n-th run, after the initial 1, of a(n) integers is the (1st, 2nd, 3rd,.., a(n)th) integer from among those positive integers which don't occur earlier in the sequence (including earlier in the same run).
%C This sequence is a permutation of the positive integers.
%H John Tyler Rascoe, <a href="/A127521/b127521.txt">Table of n, a(n) for n = 1..10000</a>
%e The beginning of the sequence grouped by runs:
%e 1,(2),(3,5),(4,7,9),(6,10,12,14,16),(8,13,17,19),(11,18,21,23,25,27,29),..
%e The n-th run, after the initial 1, has a(n) terms.
%e The 5th run has a(5)=4 terms. The positive integers which don't occur before this run are 8,11,13,15,17,18,19,20,... The first term of the 5th run is the first term of these integers, which is 8.
%e Since 8 has just occurred in the sequence, the 2nd term in the fifth run is not 11, but is instead 13. Now the positive integers that have yet to occur are 11,15,17,18,19,...For the 3rd term of the 5th run we want the 3rd of these, which is 17. And finally we want the 4th positive integer which has yet to occur in the sequence, which is 19.
%t f[l_List] := Block[{r = {}, s, c, k, m},m = Flatten[l][[Length[l]]];Do[ s = Flatten[Append[l, r]];c = i;k = 0;While[c > 0,k++;While[MemberQ[s, k], k++ ];c--;];AppendTo[r, k];, {i, m}];Append[l, r]];Flatten@Nest[f, {{1}}, 11] (* _Ray Chandler_, Jan 22 2007 *)
%Y Cf. A127522.
%K easy,nonn
%O 1,2
%A _Leroy Quet_, Jan 17 2007
%E Extended by _Ray Chandler_, Jan 22 2007