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

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A334535 a(1) = 1, a(2) = 2, and for n > 2, a(n) = 2*a(a(n-i))+a(n-1)-a(n-2) where i >= 2 is the smallest number that satisfies a(n-i) < n. 1
 1, 2, 3, 5, 8, 19, 27, 24, 45, 69, 72, 51, 27, 24, 45, 69, 72, 51, 27, 30, 57, 81, 78, 51, 75, 126, 153, 333, 486, 459, 891, 1350, 1377, 945, 486, 459, 891, 1350, 1377, 945, 486, 459, 891, 1350, 1377, 945, 486, 459, 891, 1350, 1377, 2781, 4158, 4131, 2727, 1350 (list; graph; refs; listen; history; text; internal format)
 OFFSET 1,2 COMMENTS The sequence is piecewise-periodic. LINKS Smirnov Vladimir, Table of n, a(n) for n = 1..3000 FORMULA a(n) = 2*a(a(n-i))+a(n-1)-a(n-2) where i = 2, unless a(n-i) >= n, in which case i = 3,4,5,6... EXAMPLE For n = 6, a(n-i) = a(6-2) = a(4) = 5; a(6) = 2*a(5)+a(5)-a(4) = 19. For n = 7, a(n-i) = a(7-2) = a(5) = 8; but a(n-i)>n, then a(n-i) = a(7-3) = a(4) = 5; a(7) = 2*a(5)+a(6)-a(5) = 27. For n = 9, a(n-i) = a(9-2) = a(7) = 27; but a(n-i)>n, then a(n-i) = a(9-3) = a(6) = 19; but a(n-i)>n, then a(n-i) = a(9-4) = a(5) = 8; a(9) = 2*a(8)+a(8)-a(7) = 45. Simplified calculation option for n = 31, a(n-i) = a(31-2) = a(29) = 486; but a(n-i)> n, visually find in the sequence such a(n) that is located closest to the end of the sequence and less than n: this is a(20) = 30, then a(n-i) = 30; a(31) = 2 * a(30) + a(30)- a(29) = 891. MAPLE a[1] := 1: a[2] := 2: for n from 3 to 100 do   i := 2;   while a[n-i] >= n do i := i+1;   end do:   a[n] := 2*a[a[n-i]]+a[n-1]-a[n-2] end do: seq(a[n], n=1..100); MATHEMATICA a[1]=1; a[2]=2; For[n=3, n<=100, n++, i=2; While[a[n-i]>=n, i++]; a[n]= 2*a[a[n-i]]+a[n-1]-a[n-2]]; Table[a[n], {n, 1, 100}] PROG (C) int main() { int a[100]; a[1]=1; a[2]=2; printf("%d\n", 1); printf("%d\n", 2); for (int n=3; n<=99; n++) {int i=2; while (a[n-i]>=n) {i++; } a[n]=2*a[a[n-i]]+a[n-1]-a[n-2]; printf("%d\n", a[n]); } return 0; } (PARI) lista(nn) = {my(va = vector(nn)); va[1] = 1; va[2] = 2; for (n=3, nn, my(i = 2); while(va[n-i] >= n, i++); va[n] = 2*va[va[n-i]]+va[n-1]-va[n-2]; ); va; } \\ Michel Marcus, May 09 2020 (Python) from functools import lru_cache @lru_cache(maxsize=None) def A334535(n):     if n <= 2:         return n     i, a, b = 2, A334535(n-1), A334535(n-2)     q = b     while q >= n:         i += 1         q = A334535(n-i)     return 2*A334535(q)+a-b # Chai Wah Wu, Jun 30 2020 CROSSREFS Cf. A030118. Sequence in context: A025071 A319644 A049908 * A135568 A103004 A102016 Adjacent sequences:  A334532 A334533 A334534 * A334536 A334537 A334538 KEYWORD nonn AUTHOR Smirnov Vladimir, May 05 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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified January 23 03:15 EST 2022. Contains 350504 sequences. (Running on oeis4.)