login
n occurs n times, as early as possible subject to the constraint that two successive occurrences of n are separated by at least by n terms.
5

%I #12 Nov 26 2016 10:38:47

%S 1,2,3,4,2,5,3,6,4,7,3,5,8,4,6,9,10,5,4,7,11,6,8,5,12,9,13,7,6,5,10,8,

%T 11,14,15,6,7,9,12,16,8,10,6,13,7,11,17,9,14,8,15,12,7,10,18,19,16,9,

%U 8,11,7,13,20,14,10,12,15,8,9,17,21,11,22,16,18,10,8,13,9,12,14,19,15,11

%N n occurs n times, as early as possible subject to the constraint that two successive occurrences of n are separated by at least by n terms.

%C Subsidiary sequences: first (A100919) and the last (A100920) occurrences of n.

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

%e Index of the first occurrence of 2 is 2 and that of the second occurrence is 5, separated by a(3) and a(4), two terms.

%t mx = 22; lst = cnt = ConstantArray[0, mx + 1]; a = {}; Do[k = Min@Select[Range[mx + 1], lst[[#]] <= n && cnt[[#]] < # &]; AppendTo[a, k]; lst[[k]] = n + k + 1; cnt[[k]]++; If[k > mx, Break[]], {n, mx^2}]; a (* _Ivan Neretin_, Nov 25 2016 *)

%Y Cf. A061925, A074148, A100795.

%K easy,nonn

%O 1,2

%A _Amarnath Murthy_, Dec 05 2004

%E Extended by _Ray Chandler_, Dec 08 2004