@mathlib/sequences
v1.1.2
Published
Mathematical sequence generator
Downloads
18
Maintainers
Readme
@mathlib/sequences
Mathematical sequence generator
Installation
npm install @mathlib/sequences
Usage
const sequences = require("@mathlib/sequences");
const fibonacciGenerator = sequences.fibonacci(5);
console.log([...fibonacciGenerator]); // 0, 1, 1, 2, 3
const infiniteFibonacciGenerator = sequences.fibonacci(Infinity);
for (let val of infiniteFibonacciGenerator) {
console.log(val); // 0, 1, 1, 2, 3, ..., 55, 89, 144
// Break when you have enough values
if (val > 100) break;
}
Using ES6 imports
import { fibonacci } from "@mathlib/sequences";
console.log([...fibonacci(5)]); // 0, 1, 1, 2, 3
for (let val of fibonacci(Infinity)) {
console.log(val); // 0, 1, 1, 2, 3, ..., 55, 89, 144
// Break when you have enough values
if (val > 100) break;
}
Available Sequences
| OEIS Link | Sequence ▼ | Generator | Parameters |
| --- | --- | --- | --- |
| A000142 | Factorials | factorial(limit)
| limit (Default 10) |
| A000045 | Fibonacci Series | fibonacci(limit)
| limit (Default 10) |
| A000124 | Lazy Caterer's Sequence (Central Polygonal Numbers) | lazyCaterers(limit)
| limit (Default 10) |
| A000032 | Lucas Numbers | lucas(limit)
| limit (Default 10) |
| A000027 | Natural Numbers | natural(limit)
| limit (Default 10) |
| A000129 | Pell Numbers | pell(limit)
| limit (Default 10) |
| A000073 | Tribonacci Series | tribonacci(limit)
| limit (Default 10) |
| A001477 | Whole Numbers | whole(limit)
| limit (Default 10) |