Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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;
}
Source by ide.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #javascript #fibonacci
ADD COMMENT
Topic
Name
7+2 =