首页 > 代码库 > fibonacci in c

fibonacci in c

#include<stdio.h>

long fibonacci (long n )

{

    if ( n == 1 || n == 0)  return 1;

    else

        return  fibonacci(n-1)+fibonacci(n-2);

}

 

int main(void)

{

    long n;

    scanf("%ld",&n);

    printf("%ld\n",fibonacci(n));

    return 0;

}

fibonacci in c