Guest User

Untitled

a guest
Jun 14th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include<stdio.h>
  2. int fibo(int n)
  3. {
  4. if(n == 0)
  5. {
  6. return 0;
  7. }
  8. else if(n == 1)
  9. {
  10. return 0;
  11. }
  12. else if(n == 2)
  13. {
  14. return 1;
  15. }
  16. else if(n == 3)
  17. {
  18. return 1;
  19. }
  20. else
  21. {
  22. return fibo(n-1) + fibo(n-2);
  23. }
  24. }
  25.  
  26. int main()
  27. {
  28. int n,ans;
  29. printf("Enter the value of n: ");
  30. scanf("%d",&n);
  31. ans = fibo(n);
  32. printf("The %d th element in the fibonacci series is %d",n,ans);
  33. getch();
  34. return(0);
  35. }
Add Comment
Please, Sign In to add comment