Loop_Practise_Que_02

Home / Java Practice Question / Loop_Practise_Que_02

Loop_Practise_Que_02


WAP to check a number is a part of Fibonacci Series or not...


Program - 



public class Loop{
 public boolean isFibbo(int num)
{
int a=0;
int b=1;
int c;

if(num==0 || num==1)
{
return true;
}
for(int i=2;i<=num;i++)
{
c=a+b;
a=b;
b=c;
if(c==num)
{
return true;
}
}
return false;
}
}