Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Fibonacci numbers for n terms

const getFibonacciNumbers = (n) => {
	let n1 = 0;
	let n2 = 1;
	let nextNumber;
	let fibonacciNumbers = [];

	let i = 1;
	while (i <= n) {
		fibonacciNumbers.push(n1);
		nextNumber = n1 + n2;
		n1 = n2;
		n2 = nextNumber;
	}

	return fibonacciNumbers;
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: miragejs createServer timing 
Javascript :: empty or remove div span class 
Javascript :: querySelectorAll select multiple element types 
Javascript :: Good Example: Focus moved to AJAX content with tabindex="-1" after a delay 
Javascript :: how do i block or restrict special characters from input fields with jquery 
Javascript :: board in javascript 
Javascript :: Viewing Your React App On Another Device 
Javascript :: registration page validation in react 
Javascript :: convert .js to .ts 
Javascript :: A Method In Class That Accesses A Property 
Javascript :: how to get mempool transactions and decode with ethers js 
Javascript :: jQuery mobile anchor link on the same page 
Javascript :: Enqueue jquery for TypeError: $.browser is undefined issue 
Javascript :: NextJs + Material UI, manually refreshing causes 
Javascript :: button style when clicked and unclicked react material 
Javascript :: react creating function to call API in app: calling APIs after render w error message 
Javascript :: toISOString() in electron 
Javascript :: react private routes 
Javascript :: Solution-4-C--solution options for reverse bits algorithm js 
Javascript :: set to array js 
Javascript :: remove decimal places js 
Javascript :: mounting in react 
Javascript :: javasript array 
Javascript :: arrow expression javascript 
Javascript :: react component pass props 
Javascript :: url enocde in javascript 
Javascript :: hex color js 
Javascript :: truthy or falsy 
Javascript :: javascript WeakSets Are Not iterable 
Javascript :: javascript maps 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =