Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int fibo(int n)
- {
- if(n == 0)
- {
- return 0;
- }
- else if(n == 1)
- {
- return 0;
- }
- else if(n == 2)
- {
- return 1;
- }
- else if(n == 3)
- {
- return 1;
- }
- else
- {
- return fibo(n-1) + fibo(n-2);
- }
- }
- int main()
- {
- int n,ans;
- printf("Enter the value of n: ");
- scanf("%d",&n);
- ans = fibo(n);
- printf("The %d th element in the fibonacci series is %d",n,ans);
- getch();
- return(0);
- }
Add Comment
Please, Sign In to add comment