reverse engineering - Write a function based on given TestUnit -


I need to type the function to satisfy this input -> output list:

 < Code> 0 - & gt; 0 1 - & gt; 1 3 - & gt; 2 4 - & gt; 3 5 - & gt; 5 7 - & gt; 13 9 - & gt; 34  

f (x) = ??

OK, this is incredibly easy ... / B>, you can:

  switch (input) case 0: report 0 case 1: report 1 case 3: report 2 ... default : Whatever the report is, if you want a good solution, you probably may need more constraints on the problem. You can also see whether there is a clear pattern, or perhaps show bits included in it to graph the function. It would also be useful to know whether the input and output are integer-valuable or real valuable (whether it is continuous or discrete function?). 

Edit
Showing missing numbers:

0 -> 0
> 1 -> 1
2 -> 1
3 -> 2
4 -> 3
5 -> 5
6 -> 8
7 -> 13
8 -> 21
9 -> 34

(This is a Fibonci number: f (x) = F (x -1) + F (x-2), where F (0) = 0 and F (1) = 1).

PS
This is a function for which memoanization is useful.


Comments