The nth number in Fibonacci sequence is denoted by f(n)
The golden ratio is equal to the limit of f(n)/f(n-1) as n increases without limit.
A recursive implementation of the nth number in the Fibonacci sequence in C:
unsigned long long fib(int a) {
return a>1 ? fib(a-1)+fib(a-2) : 1;
}
The above function can take a while to execute if a is sufficiently large, on my machine fib(40) takes about a second to return a value.Time taken to execute the function fib(a) is denoted by t(a).
As n increases without limit t(n)/t(n-1) approaches the golden ratio.
In practise this should give you a rough value of the golden ratio.
The reason this happens is because the function can only increase the return value by unity, one call at a time.