Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #17 Jul 08 2019 19:05:22
%S 1,3,7,11,23,35,71,75,87,159,319,321,481,483,559,583,659,1143,1303,
%T 1625,1661,1669,3295,3367,3443,4747,5331,5813,6957,12289,13915,19729,
%U 20873,22017,23643,24947,49895,51521,71251,122773,123257,123579,124163,127459,152407
%N a(n) = a(n-1) + a(a(n-1) mod n) + 1, a(0) = 1.
%F a(n) = a(n-1) + a(a(n-1) mod n) + 1, a(0) = 1.
%p a:= proc(n) option remember; `if`(n=0, 1,
%p a(n-1) + a(a(n-1) mod n) + 1)
%p end:
%p seq(a(n), n=0..50); # _Alois P. Heinz_, Jul 08 2019
%t 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 *)
%o (Java)
%o int f(int n) {
%o int[] a = new int[n + 1];
%o a[0] = 1;
%o for (int i = 1; i < n + 1; i++) a[i] = a[i - 1] + a[a[i - 1] % i] + 1;
%o return a[n];
%o }
%o (Haskell)
%o a 0 = 1
%o a n = (a (n - 1)) + (a (a (n - 1) `mod` n)) + 1
%o (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];
%o 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
%K nonn
%O 0,2
%A _Artem Yashin_, Jun 08 2019
%E More terms from _Michel Marcus_, Jun 09 2019