On Sunday, 23 October 2016 at 19:59:16 UTC, Minas Mina wrote:
On Sunday, 23 October 2016 at 13:04:30 UTC, Stefam Koch wrote:
Hi Guys,
while brushing up on my C and algorithm skills, accidently
created a version of fibbonaci which I deem to be faster then
the other ones floating around.
It's also more concise
the code is :
int computeFib(int n)
{
int t = 1;
int result = 0;
while(n--)
{
result = t - result;
t = t + result;
}
return result;
}
You can even calculate Fibonacci in O(1).
An approximation of it.