Answers for "solving fibonachchi in js"

0

javascript fibonacci example

// number fibonnaci to array format
function fibonacci(nums) {
  
  let fib = [0, 1];
  let data = [];
  
  for(let i = 2; i <= nums; i++) {
    fib[i] = fib[i - 1] + fib[i - 2]; 
    data.push(fib[i]);
  }
  
  return data;
}
Posted by: Guest on June-16-2020
0

fibonacci sums javascript

// Implement a method that finds the sum of the first n
// fibonacci numbers recursively. Assume n > 0

function fibsSum(n) {
    if ( n === 1 ) {
        return 1;
    }
    if (n === 2 ) {
        return 2;
    }
    let sum = fibsSum(n-1) + n;
    return sum;
}
Posted by: Guest on October-24-2020

Code answers related to "solving fibonachchi in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language