Enter number to check Fibonacci are not
#include <stdio.h>
int main()
{
int num;
int i, y, z, b;
short fibonacci;
y = 1;
z = 1;
b = 1;
fibonacci = 0;
printf("Enter a Number: ");
scanf("%d", &num);
for (i = 1; i < num; i++)
{
z = y;
y = b;
b = z+y;
if (b == num)
{
fibonacci = 1;
break;
}
}
if (fibonacci == 1)
printf("Number is Fibonacci");
else
printf("Number is not Fibonacci");
}
Comments
Leave a comment