This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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

Win a copy of Java 8 in Action this week in the Java 8 forum!
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");
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: checking wether fibanocci or not
Similar Threads
Optimization Java Code - performance Vs memory
logging into linux machine through java
can we test JSP,Struts pages using HttpUnit
Unexpected thread behavior
Java program for fibanocci using Java threads