login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A336604 a(0) = 1, a(1) = 2; thereafter let x = (a(n-1) mod a(n-2)); then a(n) = a(n-1) + a(x) if x < n, otherwise a(n) = a(n-1). 1
1, 2, 3, 5, 8, 13, 26, 27, 29, 32, 37, 50, 50, 51, 53, 56, 61, 74, 125, 125, 126, 128, 131, 136, 149, 200, 200, 201, 203, 206, 211, 224, 275, 275, 276, 278, 281, 286, 299, 350, 350, 351, 353, 356, 361, 374, 425, 425, 426, 428, 431, 436, 449, 500, 936, 936, 937, 939, 942, 947, 960, 1011 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
LINKS
EXAMPLE
a(7) = 27, a(8) = 29, so a(9) = 29 + a(29 mod 27) = 32.
MAPLE
a:= proc(n) option remember; `if`(n<2, n+1, (x->
a(n-1)+`if`(x<n, a(x), 0))(a(n-1) mod a(n-2)))
end:
seq(a(n), n=0..100); # Alois P. Heinz, Oct 25 2020
MATHEMATICA
a[0] = 1; a[1] = 2; a[n_] := a[n] = a[n - 1] + If[(r = Mod[a[n - 1], a[n - 2]]) < n, a[r], 0]; Array[a, 51, 0] (* Amiram Eldar, Oct 10 2020 *)
PROG
(C++)
for (int i = 2; i < 10000; i++)
{
j = a[i - 1];
k = a[i - 2];
l = j % k;
if (int(l) <= int(i)) a[i] = j + a[l]; else a[i] = a[i - 1];
}
CROSSREFS
Cf. A215526.
Sequence in context: A125730 A340708 A074030 * A024318 A324738 A132915
KEYWORD
nonn
AUTHOR
Maxim Skorohodov, Oct 10 2020
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 07:07 EDT 2024. Contains 371964 sequences. (Running on oeis4.)