// Fibonacci number generator in ANSI C using recursion #include #include #define COUNT 30 long Fibo (long x); long Fibo (long x) { if (x < 3) return 1; else return Fibo (x-1) + Fibo (x-2); } int main (int argc, const char * argv[]) { long fibo; int i; clock_t start, done; start = clock(); printf("Lasketaan fibo %d \n", COUNT); for (i = 1; i <= COUNT; i++) { fibo = Fibo (i); printf ("Fibo: %d - %ld\n",i, fibo); } done = clock(); printf("Laskenta kesti: %f sec\n",(done-start)/(double)(CLOCKS_PER_SEC)); return 0; }