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

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

Jwenting allready did that ...
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 :");
num=reader.nextInt();
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 3 Years Ago by mike_2000_17: Fixed formatting

Comments
don't help homework kiddos, read the rules

Compile it, run it, play around with it, etc. If you get a syntax error tell us the line and we will help you. If you get a bug specify what the code is doing wrong. If the code is simply "not working" as in your algorithm is completely wrong because your answers are totally off, then try rewriting the algorithm (we aren't helping with that part).

Edited 6 Years Ago by kvass: n/a

This article has been dead for over six months. Start a new discussion instead.