← Back to challenges

Fibonacci Sequence

JavaScriptHardmathloops

Instructions

The Fibonacci Sequence is the sequence of numbers (Fibonacci Numbers) whose sum is the two preceding numbers (e.g. 0, 1, 1, 2, 3, etc). Using 0 and 1 as the starting values, create a function that returns an array containing all of the Fibonacci numbers less than 255.

Examples

On generating a Fibonacci number where input is the two preceding values starting from 0 and 1 [0, 1, ...].

fibonacciSequence(0, 1) ➞ 1

fibonacciSequence(1, 1) ➞ 2

fibonacciSequence(1, 2) ➞ 3

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Simple Numbers