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:
the number is a fibonacci number
the number is not a fibonacci number

8 Years
Discussion Span
Last Post by kvass

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


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");
    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

Votes + 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 by kvass: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.