Skip to content

string-data-structure/fibonacci-string

Repository files navigation

Fibonacci string for JavaScript. See docs.

⚠️ Depending on your environment, the code may require regeneratorRuntime to be defined, for instance by importing regenerator-runtime/runtime.

import {makeIndex, query} from '@string-data-structure/fibonacci-string';

const F = makeIndex({iadd: (x, y) => x+y, zero: () => 1, one: () => 2}, 10);

query(F, 0); // 0
query(F, 1); // 1
query(F, 2); // 0
query(F, 3); // 0
query(F, 4); // 1
query(F, 5); // 0
query(F, 6); // 1
query(F, 7); // 0
query(F, 8); // 0
query(F, 9); // 1
query(F, 10); // 0

const Fn = makeIndex({iadd: (x, y) => x+y, zero: () => 1n, one: () => 2n}, 10n**100n);
query(Fn, 4802349082340928340983n); // 1n
query(Fn, 123456748023490823409283409834802349082340928340983n); // 0n

License Version Tests Dependencies GitHub issues Downloads

Code issues Code maintainability Code coverage (cov) Code technical debt Documentation Package size