/* C Program To Check Whether The Given Number Is A Fibonacci Number Or Not */ #include<stdio.h> #include<conio.h> void main() { int f1,f2,f3,next,num; printf("Enter the number to be determined:\n"); scanf("%d", &num); if((num==0)||(num==1)) printf("%d is a Fibonacci term",num); else { f1=0; f2=1; f3=f1+f2; while(f3<num) { f1=f2; f2=f3; f3=f1+f2; } if(f3==num) printf("%d is a Fibonacci term",num); else printf("%d is not a Fibonacci term",num); } }
Enter the number to be determined: 13 13 is a Fibonacci term
No comments:
Post a Comment