C Program:
/*program to check the number is fibonacci or not*/
#include<stdio.h>
#include<conio.h>
void main()
{
int f=1,f1=1,f2=0,n;
clrscr();
printf("Enter the number to be checked\n");
scanf("%d ",&n);
while(f<n)
{
f=f1+f2;
f1=f2;
f2=f;
}
if(f==n)
printf("%d is fibonacci\n",n);
else
printf("%d is not fibonacci\n",n);
getch();
}
OUTPUT:
/*program to check the number is fibonacci or not*/
#include<stdio.h>
#include<conio.h>
void main()
{
int f=1,f1=1,f2=0,n;
clrscr();
printf("Enter the number to be checked\n");
scanf("%d ",&n);
while(f<n)
{
f=f1+f2;
f1=f2;
f2=f;
}
if(f==n)
printf("%d is fibonacci\n",n);
else
printf("%d is not fibonacci\n",n);
getch();
}
OUTPUT:
0 Comments