Fibonacci Sequence

Generate the first N numbers of the Fibonacci sequence where each number is the sum of the two preceding ones.

Code

Algorithms
Array.from({ length: n }).reduce((acc, _, i) => [...acc, i < 2 ? i : acc[i-1] + acc[i-2]], []);

Parameters

Number of Fibonacci numbers to generate

Browser·fetch() may be limited by CORS

More JavaScript Snippets