Ad

The function take a number and checks if it is in the Fibonnacci Sequence. If it is return "yes", else return "no".

Fibonnacci sequence explained:
starts with 0 and 1. It adds the two previous numbers to get the next one, then continues the pattern.

Some of the beginning sequence: 0,1,1,2,3,5,8,13,21...

function isSquare(x) { 

  // code goes here  
  let sq = parseInt(Math.sqrt(x));
  return check = (sq * sq == x)
}

function FibonacciChecker(num){
  return (isSquare(5 * num * num + 4) || isSquare(5 * num * num -4)) ? "yes" : "no";
  
}
Code
Diff
  • function factorial(n) { return n == 1 ? 1 : n * factorial(n - 1) }
    
    • function factorial (n) {
    • if (n === 1) {
    • return 1;
    • } else {
    • return n * factorial(n - 1);
    • }
    • }
    • function factorial(n) { return n == 1 ? 1 : n * factorial(n - 1) }