Fibonacci iterator provide an iteratable instance that generate a fibonacci sequence.
See Wikipedia - Fibonacci number.
Note: this iterator is an infinity iterator, add a break point, or it will go infinity loop.
import { FibonacciIterator } from "@sudoo/iterator";
const iterator: FibonacciIterator = FibonacciIterator.create();
const query: number[] = [];
for (const next of iterator) {
if (count >= 5) {
break;
}
query.push(next);
}
query // [1, 2, 3, 5, 8]