4

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]

  • @BrianM.Scott: yes, my mistake. It seems to be quite complicated. Also OEIS gives no match. – Andreas H. Jan 07 '15 at 19:55
  • 1
    Have you seen this? http://math.stackexchange.com/q/1053112/97045 – DanielV Jan 07 '15 at 21:40
  • @DanielV Thanks, unfortunately I have no idea what is going on in that explanation and it will take a bit of reading to understand it. – John Drake Jan 07 '15 at 21:46
  • @JohnDrake Indeed, that is why I didn't flag this as duplicate, since the given answer is fairly hard to understand (it is a hard problem to begin with) that asking for further help or generalization might be appreciated (my opinion not necessarily site policy). – DanielV Jan 07 '15 at 21:53
  • There's this too. My solution there is pretty elementary. – Milo Brandt Jan 07 '15 at 23:17
  • @Meelo Thanks! The object here is purely computational speed, and I don't really care how it's achieved. If you were wondering this problem has appeared four times in the last month as a result of an invitational set of problems presented by a tech company, and the programmers who attempt them are being baffled by the maths in this one. – John Drake Jan 08 '15 at 01:51

0 Answers0