How can I convert a recursive equation to a non-recursion one?

123 Views Asked by At

While I am aware of several other similar question which have been asked in the past, my mathematical education only extends through calculus, making them beyond my comprehension, and I believe this specific problem is harder because of the (2n) component. I would like to convert the below function into a non recursive one (to reduce its compute time), and would greatly appreciate any explanation for how to do so, especially if they don't require advanced knowledge, or the solution. Thanks!

$$\begin{align} R(0) &= 1 \\ R(1) &= 1 \\ R(2) &= 2 \\ R(2n) &= R(n) + R(n + 1) + n \quad\quad (\text{for } n > 1) \\ R(2n + 1) &= R(n - 1) + R(n) + 1 \quad\quad (\text{for } n \ge 1) \\ \end{align}$$

(n is a whole number)

Edit: Here is a list of the first 40 elements.
[1,1,2,3,7,4,13,6,15,11,22,12,25,18,28,20,34,22,42,27,44,34,48,35,55,38,59,44,62,47,69,49,72,55,81,57,87,65,90,70]