[OT] fastest fibbonacci

Stefam Koch via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 23 06:04:30 PDT 2016


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;
}



More information about the Digitalmars-d mailing list