login
Start of first run of length n in Golomb's sequence A001462.
1

%I #17 Oct 07 2015 09:55:30

%S 1,2,6,12,24,39,63,91,123,168,218,273,345,423,507,597,709,828,954,

%T 1087,1247,1415,1591,1775,1991,2216,2450,2693,2945,3235,3535,3845,

%U 4165,4495,4869,5254,5650,6057,6475,6943,7423,7915,8419,8935,9463,10048,10646,11257,11881,12518

%N Start of first run of length n in Golomb's sequence A001462.

%C The first run of length n in A001462 begins with A095114(n), i.e., A001462(a(n)) = A095114(n).

%C a(n) = A095114(A095114(n)).

%F a(1) = 1; a(n+1) = a(n) + A001462(n)*n.

%e Since Golomb's sequence starts 1,2,2,3,3,4,4,4,5,... the first run of length three starts at position 6, so a(3) = 6.

%t a[1] = 1; a[n_] := a[n] = 1 + a[n - a[a[n - 1]]]; s = Array[a, {13000}]; t = Most@ Map[Last, Tally@ s]; Table[Total@ Take[t, First@ Flatten@ Position[t, n]] - n + 1, {n, 50}] (* _Michael De Vlieger_, Oct 07 2015, after _Robert G. Wilson v_ at A001462 *)

%o (PARI) a(n) = if (n<2, 1, a(n-1)+ t(n-1)*(n-1));

%o t(n) = local(A, t, i); if(n<3, max(0, n), A=vector(n); t=A[i=2]=2; for(k=3, n, A[k]=A[k-1]+if(t--==0, t=A[i++ ]; 1)); A[n]);

%o vector(100, n, a(n))\\ _Altug Alkan_, Oct 06 2015

%Y Cf. A001462, A095114.

%K nonn

%O 1,2

%A _Glen Whitney_, Oct 06 2015

%E More terms from _Altug Alkan_, Oct 06 2015