#include
int isSquare(int num);
main()
{
int num, temp;
printf("Enter the number\n");
scanf("%d", &num);
temp = 5 *(num * num) - 4;
if(isSquare(temp) || isSquare(temp+8)){
printf("It is finonacci number\n");
}else {
printf("It is NOT finonacci number\n");
}
}
int isSquare(int num)
{
int i=1;
while(num>0)
{
num = num - i;
i = i+2;
}
if(num==0)
return 1;
else
return 0;
}
1 comment:
Yes, I have cheeked it. It is Fibonacci series program. Enter 5, you got output as :
0 1 1 2 3 5..
dhea
Post a Comment