title: Java: check if number belongs to Fibonacci sequence
body: <p>I'm supposed to write a code which checks if a given number belongs to the Fibonacci sequence. After a few hours of hard work this is what i came up with:</p>
  
  <pre><code>public class TP2 {
  
      /**
       * @param args
       */
  
      public static boolean ehFibonacci(int n) {
          int fib1 = 0;
          int fib2 = 1;
          do {
              int saveFib1 = fib1;
              fib1 = fib2;
              fib2 = saveFib1 + fib2;
              }
          while (fib2 &lt;= n);
  
          if (fib2 == n)
              return true;
          else
              return false;
  
      }
      public static void main(String[] args) {
          int n = 8;
          System.out.println(ehFibonacci(n));
  
      }
  }
  </code></pre>
  
  <p>I must be doing something wrong, because it always returns "false". Any tips on how to fix this?</p>