Advertisement
Guest User

fibonacci

a guest
Nov 25th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4.  
  5. int fibonacci(int n)
  6. {
  7. if(n==0 || n==1)
  8. return n;
  9. else{
  10. return fibonacci(n-1)+fibonacci(n-2);
  11. }
  12. }
  13.  
  14. int main()
  15. {
  16. int n, c;
  17. printf("Fibonacci series of N elements:\n");
  18. scanf("%d", &n);
  19. for(c=0; c<n; c++)
  20. printf("%d ", fibonacci(c));
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement