login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A308576
a(n) = a(n-1) + a(a(n-1) mod n) + 1, a(0) = 1.
0
1, 3, 7, 11, 23, 35, 71, 75, 87, 159, 319, 321, 481, 483, 559, 583, 659, 1143, 1303, 1625, 1661, 1669, 3295, 3367, 3443, 4747, 5331, 5813, 6957, 12289, 13915, 19729, 20873, 22017, 23643, 24947, 49895, 51521, 71251, 122773, 123257, 123579, 124163, 127459, 152407
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
Sequence in context: A192614 A112715 A106935 * A116362 A090918 A139253
KEYWORD
nonn
AUTHOR
Artem Yashin, Jun 08 2019
EXTENSIONS
More terms from Michel Marcus, Jun 09 2019
STATUS
approved