Re: FIbonacci



MARQUITOS51 wrote:
> Hey guys this is the fibonacci series. But Im having this huge problem.
> First of all I want to do the simplest code possible so then I can use
> user defined functions and arrays. But this one didnt came out well.
> Any suggestions!
>

#include <stdio.h>

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

int main(void) { printf("fib(17) is: %d\n", fib(17)); return 0; }


P.Krumins

.



Relevant Pages

  • FIbonacci
    ... Hey guys this is the fibonacci series. ... First of all I want to do the simplest code possible so then I can use ... int fib, n; ...
    (comp.lang.c)
  • Re: FIbonacci
    ... > Hey guys this is the fibonacci series. ... > First of all I want to do the simplest code possible so then I can use ... > int fib, n; ... First it starts with 1 and 1, the third element of fibonacci series is the ...
    (comp.lang.c)