@mathlib/sequences
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

@mathlib/sequences

Mathematical sequence generator

Build & Test

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)

Package Sidebar

Install

npm i @mathlib/sequences

Weekly Downloads

4

Version

1.1.2

License

MIT

Unpacked Size

9.41 kB

Total Files

21

Last publish

Collaborators

  • butane