login
Limiting sequence when we start with positive integers (A000027) and at step n >= 1 add to the term at position n + a(n) the value n.
3

%I #21 May 01 2021 11:43:09

%S 1,3,3,4,7,9,7,12,9,10,11,17,13,21,21,16,17,27,19,38,21,33,23,24,25,

%T 39,27,28,41,30,31,48,33,51,49,51,37,57,39,40,41,63,43,44,63,69,47,72,

%U 49,75,51,52,53,81,77,84,57,78,59,90,61,93,63,64,91,99,67,68,69,99

%N Limiting sequence when we start with positive integers (A000027) and at step n >= 1 add to the term at position n + a(n) the value n.

%H Alois P. Heinz, <a href="/A137894/b137894.txt">Table of n, a(n) for n = 1..10000</a>

%F Limiting sequence when we start with positive integers (A000027) and at step n >= 1 add to the term at position n + a(n) the value n.

%p mx:= 10000: # maximal index needed

%p b:= proc(n) n end:

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

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

%p if n+t<=mx then h:=b(t+n); b(t+n):=h+n fi; t

%p fi

%p end:

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

%t mx = 10000 (* maximal index needed *); b[n_] := n; a[n_] := a[n] = Module[{h, t}, If[n == 0, 0, a[n-1]; t = b[n]; If[n+t <= mx, h = b[t+n]; b[t+n] = h+n]; t]]; Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, Oct 24 2016, after _Alois P. Heinz_ *)

%o (Python)

%o TOP = 1000

%o a = [1]*TOP

%o for n in range(1,TOP):

%o a[n]=n

%o for n in range(1,TOP):

%o print(str(a[n]),end=',')

%o if n+a[n]<TOP: a[n+a[n]] += n

%o # _Alex Ratushnyak_, Nov 22 2013

%Y Cf. A000027, A136119, A137319, A137417, A137418, A136259, A136272.

%K easy,nonn

%O 1,2

%A _Ctibor O. Zizka_, Apr 30 2008

%E More terms from _Alex Ratushnyak_, Nov 22 2013.