Creates an infinite generator that yields the Fibonacci sequence.
First starting value, defaults to 0
Second starting value, defaults to 1
An infinite generator of Fibonacci numbers
Fibonacci numbers in sequence
// Generate standard Fibonacci sequenceconst fib = fibonacci()const first8 = Array.from({ length: 8 }, () => fib.next().value)// Result: [1, 1, 2, 3, 5, 8, 13, 21] Copy
// Generate standard Fibonacci sequenceconst fib = fibonacci()const first8 = Array.from({ length: 8 }, () => fib.next().value)// Result: [1, 1, 2, 3, 5, 8, 13, 21]
// Generate Fibonacci sequence with custom starting valuesconst fib = fibonacci(2, 3)const first6 = Array.from({ length: 6 }, () => fib.next().value)// Result: [3, 5, 8, 13, 21, 34] Copy
// Generate Fibonacci sequence with custom starting valuesconst fib = fibonacci(2, 3)const first6 = Array.from({ length: 6 }, () => fib.next().value)// Result: [3, 5, 8, 13, 21, 34]
Creates an infinite generator that yields the Fibonacci sequence.