Advertisement
Guest User

Untitled

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