[Shootout-list] Problems building GCC C Fibonacci.

Dave davejf@frontiernet.net
Sun, 20 Mar 2005 20:11:59 -0600


----- Original Message ----- 
From: "Isaac Gouy" <igouy2@yahoo.com>
To: "Dave" <davejf@frontiernet.net>; <shootout-list@lists.alioth.debian.org>
Sent: Sunday, March 20, 2005 5:05 PM
Subject: Re: [Shootout-list] Problems building GCC C Fibonacci.


> Thanks, I was wondering who I'd managed to get all the other
> implementations to fail but GCC still gave the old result ;-)
>
> Umm please could you produce a corrected version?
>

Here is a corrected version - Thanks.

/* -*- mode: c -*-
 * $Id: fibo-gcc.code,v 1.9 2005/03/19 04:35:53 bfulgham Exp $
 * http://shootout.alioth.debian.org/
 */

#include <stdio.h>
#include <stdlib.h>

unsigned long
fib(unsigned long n) {
    return( (n < 2) ? n : (fib(n-2) + fib(n-1)) );
}

int
main(int argc, char *argv[]) {
    int N = ((argc == 2) ? atoi(argv[1]) : 1);
    printf("%ld\n", fib(N));
    return(0);
}

> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> _______________________________________________
> Shootout-list mailing list
> Shootout-list@lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/shootout-list
>
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.7.4 - Release Date: 3/18/2005
>
>