OFFSET
0,3
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 0..5000
EXAMPLE
a(14) = a(13) + a(a(13) mod 14) = 94 + a(94 mod 14) = 94 + a(10) = 94 + 38 = 132.
MAPLE
f:=proc(n) option remember;
if n <= 1 then n else f(n-1)+f(f(n-1) mod n); fi; end;
[seq(f(n), n=0..32)]; # N. J. A. Sloane, May 04 2016
MATHEMATICA
f[l_List] := Append[l, l[[ -1]] + l[[Mod[l[[ -1]], Length[l]] + 1]]]; Nest[f, {0, 1}, 50] (* Ray Chandler, Jan 23 2007 *)
l = {0, 1}; Do[x = l[[n]] + l[[Mod[l[[n]], n] + 1]]; AppendTo[l, x], {n, 2, 50}]; l (* Ryan Propper, Jan 24 2007 *)
PROG
(Python)
from sympy.core.cache import cacheit
@cacheit
def a(n): return n if n<2 else a(n - 1) + a(a(n - 1)%n)
print([a(n) for n in range(51)]) # Indranil Ghosh, Aug 07 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Jan 13 2007
EXTENSIONS
Extended by Ray Chandler and Robert G. Wilson v, Jan 23 2007
More terms from Ryan Propper, Jan 24 2007
STATUS
approved