Created
May 10, 2021 06:50
-
-
Save jagdish4501/bef3efba493b82272e43529940d06b4f to your computer and use it in GitHub Desktop.
Q.finding nth term of fibnoc series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* finding n th term of fibnoci series*/ | |
#include <stdio.h> | |
int fibnoci(int i); | |
int main() | |
{ | |
int fib, n; | |
printf(" Enter number :"); | |
scanf("%d", &n); | |
fib = fibnoci(n); | |
printf(" fibnoci of %d is =%d", n, fib); | |
} | |
int fibnoci(int i) | |
{ | |
if (i == 0 || i == 1) | |
{ | |
if (i == 0) | |
{ | |
return 0; | |
} | |
else | |
return 1; | |
} | |
else | |
return fibnoci(i - 1) + fibnoci(i - 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment