OFFSET
0,2
FORMULA
a(n) = a(n-1) + a(a(n-1) mod n) + 1, a(0) = 1.
MAPLE
a:= proc(n) option remember; `if`(n=0, 1,
a(n-1) + a(a(n-1) mod n) + 1)
end:
seq(a(n), n=0..50); # Alois P. Heinz, Jul 08 2019
MATHEMATICA
a[0]=1; a[n_] := a[n] = a[n-1] + a[Mod[a[n-1], n]] + 1; Array[a, 50, 0] (* Amiram Eldar, Jul 08 2019 *)
PROG
(Java)
int f(int n) {
int[] a = new int[n + 1];
a[0] = 1;
for (int i = 1; i < n + 1; i++) a[i] = a[i - 1] + a[a[i - 1] % i] + 1;
return a[n];
}
(Haskell)
a 0 = 1
a n = (a (n - 1)) + (a (a (n - 1) `mod` n)) + 1
(PARI) getV(n, v) = if (!v[n+1], v[n+1] = getV(n-1, v) + getV(getV(n-1, v) % n, v) + 1); v[n+1];
lista(nn) = {my(v=vector(nn+1)); v[1] = 1; for (n=1, nn, v[n+1] = getV(n, v); ); v; } \\ Michel Marcus, Jun 09 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Artem Yashin, Jun 08 2019
EXTENSIONS
More terms from Michel Marcus, Jun 09 2019
STATUS
approved