login
Limiting sequence of transformations when we start with the all 1's sequence a=A000012 and at step n>=0 replace a(n+a(n)) with Sum_{k=n..n+a(n)} a(k).
2

%I #58 Nov 13 2020 02:41:39

%S 1,2,1,5,1,2,1,5,10,1,2,1,23,1,2,1,5,1,39,1,2,47,50,1,2,1,5,1,2,1,5,

%T 10,1,2,1,105,1,2,1,5,1,121,1,2,129,132,1,2,1,5,1,2,1,5,10,1,2,206,

%U 432,1,2,1,5,1,449,1,2,457,889,1,2,1,820,1,2,1,5,1

%N Limiting sequence of transformations when we start with the all 1's sequence a=A000012 and at step n>=0 replace a(n+a(n)) with Sum_{k=n..n+a(n)} a(k).

%H Alois P. Heinz, <a href="/A246964/b246964.txt">Table of n, a(n) for n = 0..20000</a>

%e Start . . . . . . . . . . . . . . . . . : 1,1,1,1,1,...

%e Step 0: a(0+a(0)) = a(1)<- a(0)+a(1) = 2 : 1,2,1,1,1,...

%e Step 1: a(1+a(1)) = a(3)<- a(1)+a(2)+a(3) = 4 : 1,2,1,4,1,...

%e Step 2: a(2+a(2)) = a(3)<- a(2)+a(3) = 5 : 1,2,1,5,1,...

%p mx:= 20000: # maximal index needed

%p b:= proc() 1 end:

%p a:= proc(n) option remember; global mx; local t;

%p if n<0 then 0 else a(n-1); t:= b(n);

%p if n+t<= mx then b(n+t):= add(b(k), k=n..n+t) fi; t

%p fi

%p end:

%p seq(a(n), n=0..100); # _Alois P. Heinz_, Mar 04 2015

%t mx = 20000; (* Maximal index needed *)

%t b[_] = 1;

%t a[n_] := a[n] = Module[{t}, If[n<0, 0, t = b[n]; If[n+t <= mx, b[n+t] = Sum[b[k], {k, n, n+t}]]; t]];

%t a /@ Range[0, 100] (* _Jean-François Alcover_, Nov 13 2020, after _Alois P. Heinz_ *)

%K nonn,look

%O 0,2

%A _Floor van Lamoen_, Mar 02 2015