Fibonacci Recursion using Golden Ratio(Golden Number)
algorithm, c, fibonacci
Solution
The golden ratio is an irrational number, so you shouldn't necessarily expect to be able to plug an approximation of it into a formula to get an exact result.
If you want to know how to calculate the `n`th fibonacci number quickly, here is a page that lists a variety of methods in decreasing order of runtime (but increasing in order of implementation difficulty): https://www.nayuki.io/page/fast-fibonacci-algorithms
Problem
i can do a recursive function to compute the nth Fibonacci term as follows: ``` int rec (int i) { if(i == 1 || i == 2) return i; else return rec(i-1)+rec(i-2); ``` } But i want to use the golden number which is 1.618 to compute the Fibonacci; but my attempt fails, i get wrong numbers: ``` int rec (int i) { if(i == 1 || i == 2) return i; else return 1.618*rec(i-1); } ``` How can i get it to work?