title: Check the given number belongs to Fibonacci sequence in node.js?
body: <p>I need to create a web server with rest service in node.js. The server have to find a given input is Fibonacci or not. If it is Fibonacci, find the next number in Fibonacci sequence.</p>
  
  <p>So I just write a simple program for finding Fibonacci number, but it doesn't work. </p>
  
  <p>Following are the Javascript functions I tried:</p>
  
  <pre><code>var n = 5,s, a, fib;
  
  function isPerfectSquare(s)
  {
      var a = Math.sqrt(s);
      return a * a == s;
  }    
  function isFibonacci(n)
  {
      s = (5 * Math.pow(n, 2) + 4 || 5 * Math.pow(n, 2) - 4)
      return s;
  }
  
  //How to fix this line. I don't know how to check perfect square conditions 
  if(isPerfectSquare(isFibonacci(n)) || isPerfectSquare(isFibonacci(n)))
  {
      fib = Math.round(n * 1.618); // finds the next fibonacci series of given input
      console.log("The next Fibonacci number is " + fib);
  }    
  else
  {
      console.log("The given number is not a fibonacci number");
  }
  </code></pre>