Skip to content

Instantly share code, notes, and snippets.

@jagdish4501
Created May 10, 2021 06:50
Show Gist options
  • Save jagdish4501/bef3efba493b82272e43529940d06b4f to your computer and use it in GitHub Desktop.
Save jagdish4501/bef3efba493b82272e43529940d06b4f to your computer and use it in GitHub Desktop.
Q.finding nth term of fibnoc series
/* 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