Fibonacci Series

PHOTO EMBED

Thu Nov 05 2020 11:58:30 GMT+0000 (UTC)

Saved by @snigdhakhurana10

function fibonacci(numberOfItems){
	let num1 = 0, num2 = 1, fibArr=[];
	fibArr.push(num1);
    fibArr.push(num2);
    for(let i=0; i<numberOfItems -2; i++){
		let sum = num1 + num2;
		fibArr.push(sum);
        num1 = num2;
        num2 = sum;
	}
    return fibArr;
}

console.log(fibonacci(8));
content_copyCOPY