#include<stdio.h>
int main()
{
int term1=0, term2=1, nextTerm=0, nthterm, last;
printf(" Please enter the nth-fibonacci ");
scanf("%d", &nthterm);
nextTerm=term1+term2;
while(nextTerm<nthterm)
{
term1=term2;
term2=nextTerm;
nextTerm=term1+term2;
}
printf("%d",term2);
return 0;
}
Comments
Leave a comment