Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

checking wether fibanocci or not

 
ramjcp kris
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can an one suggest me a program/algorithm to check wether entered number is fibanocci or not; I have written the program to generate fibanocci series ,its working fine.
 
Stephen Foy
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could assign the fibonacci series to an array.

And then check like:


[ December 08, 2005: Message edited by: ste fing ]
 
Sri Ram
Ranch Hand
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U can use this


N is a Fibonacci number if and only if 5 N2 + 4 or 5 N2 � 4 is a square number.


write a program implementing this rule, u get the Result
 
georgy jacob
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope this code will be of use to you

int sum;
int i=0;
int j=1;
boolean fibo_flag = false;
do
{
sum = i+j;
i=j;
j=sum;
if(entered_num==0 || entered_num == sum)fibo_flag=true;
}
while (sum<entered_num);
if(fibo_flag) System.out.println("Numbr is fibonacci");
else System.out.println("Number is not fibonacci");
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic