File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes  checking wether fibanocci or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " checking wether fibanocci or not" Watch " checking wether fibanocci or not" New topic

checking wether fibanocci or not

ramjcp kris

Joined: Sep 05, 2005
Posts: 27
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

Joined: Oct 17, 2005
Posts: 143
you could assign the fibonacci series to an array.

And then check like:

[ December 08, 2005: Message edited by: ste fing ]

Stephen Foy - Microsoft Application Development Consultant
Sri Ram
Ranch Hand

Joined: Oct 03, 2005
Posts: 118
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

Joined: Nov 23, 2005
Posts: 53
I hope this code will be of use to you

int sum;
int i=0;
int j=1;
boolean fibo_flag = false;
sum = i+j;
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:
subject: checking wether fibanocci or not
It's not a secret anymore!