its java assignment
i dont know how to do this part

allow user to determine whether a given (whole ) number is a Fibonacci number or not

print massage on the screen with the result of your option:
either
the number is a fibonacci number
or
the number is not a fibonacci number

4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by kvass
``````if (fibonaci) {
print message 1;
else {
print message 2;
}``````

One method you can use is to start off with 2 integers that store the beginning of the Fibonacci sequence and loop through to modify them and iterate through the sequence. If one of the values exceeds the number you are checking, you passed it, so you know it's not a fib number. If you hit the number, then it is a fib number.

Hi kvass
ammmm can you explaine it with the code

Hi kvass
ammmm can you explaine it with the code

just google 'fibonnaci' and program it.
don't just assume making your assignments is the biggest thrill or honour we're hoping to achieve here

ok
i did it like this

``````    int k
int l;
System.out.println("Enter an integer :");
for (l=2;l < k ;l++ ){
int y = k%l;
if (y==0){
System.out.println(k+"is not a fibonacci");
break;
}
}
if(l== k){
System.out.println(k+"is a fibonacci ");
``````

but i dont know what is the problem

Edited by mike_2000_17: Fixed formatting