Answers for "javascript fibonacci to array"

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
-2

fibonacci counter in typescript

'use strict';

let fibonacci: number[] = [0, 1];

function listFibonacci(num: number) {
  for (let i: number = 2; i < num; i++) {
    fibonacci[i] = fibonacci[i - 2] + fibonacci[i - 1];
  }
  return fibonacci;
}
console.log(listFibonacci(10));
Posted by: Guest on December-09-2020

Code answers related to "javascript fibonacci to array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language