Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. int fibn(int n);
  3. int main()
  4. {
  5. int i, n;
  6. printf("Enter the number of items to show in fibonacci series: ");
  7. scanf("%d", &n);
  8. printf("The fibonacci series is: \n");
  9.  
  10. for(i = 0; i < n;i++)
  11. printf("%d \n", fibn(i));
  12.  
  13.  
  14. }
  15. int fibn(int n)
  16. {
  17. if (n==0)
  18. return 0;
  19. else if (n==1)
  20. return 1;
  21. else
  22. return fibn(n-1)+fibn(n-2);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement