Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. int Fibonacci(int);
  2.  
  3. main()
  4. {
  5.    int n, i = 0, c;
  6.  
  7.    scanf("%d",&n);
  8.  
  9.    printf("Fibonacci series\n");
  10.  
  11.    for ( c = 1 ; c <= n ; c++ )
  12.    {
  13.       printf("%d\n", Fibonacci(i));
  14.       i++;
  15.    }
  16.  
  17.    return 0;
  18. }
  19.  
  20. int Fibonacci(int n)
  21. {
  22.    if ( n == 0 )
  23.       return 0;
  24.    else if ( n == 1 )
  25.       return 1;
  26.    else
  27.       return ( Fibonacci(n-1) + Fibonacci(n-2) );
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement