Header Ads Widget

Program to find the Nth term of the fibonacci series

 what is fibonacci series:- 

                     In the fibonacci series every elements are the some of two elements before it.

Fibonacci Sequence = 0, 1, 1, 2, 3, 5, 8, 13, 21, ….


 Code (c):-

#include<stdio.h>
int main()
{
int n;
printf("Enter the term of the series\n");
scanf("%d",&n);
if(n==1)
printf("0");
else if(n==2)
printf("1");
else
{
int pp=0,p=1,nx,k=3;
nx=pp+p;
printf("%d of the series is ",n);
for(int i=3;i<n;i++)
{
pp=p;
p=nx;
nx=pp+p;
}
printf("%d",nx);
}
return 0;
}

Output:-

5
Enter the term of the series
5 of the series is 3


Recommended Post:-

codechef problems:-

Wipro :-

Infytq :-

Key Points;-

Hackerrank:-


C-tutorial:-

See more:-