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

Recommended Answers

All 7 Replies

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

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

commented: don't help homework kiddos, read the rules -2

no, you're not going to trick us into doing your homework for you.

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.