daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top