title: Determining whether a number is a Fibonacci number
body: <p>I need to to write a Java code that checks whether the user inputed number is in the Fibonacci sequence. </p>
  
  <p>I have no issue writing the Fibonacci sequence to output, but (probably because its late at night) I'm struggling to think of the sequence of "whether" it is a Fibonacci number. I keep starting over and over again. Its really doing my head in. </p>
  
  <p>What I currently have is the nth.  </p>
  
  <pre><code>public static void main(String[] args)
  {
      ConsoleReader console = new ConsoleReader();
  
      System.out.println("Enter the value for your n: ");
      int num = (console.readInt());
      System.out.println("\nThe largest nth fibonacci: "+fib(num));
      System.out.println();
  }
  
  static int fib(int n){
      int f = 0;
      int g = 1;
      int largeNum = -1;
      for(int i = 0; i &lt; n; i++)
      {
        if(i == (n-1))
            largeNum = f;
        System.out.print(f + " ");
        f = f + g;
        g = f - g;
      }
      return largeNum;
  }
  </code></pre>