Tweakr
    Preparing search index...

    Function fibonacci

    • Computes the n-th Fibonacci number using memoization and BigInt.

      Uses an internal cache to store results for improved performance. Automatically switches to BigInt for large values.

      Parameters

      • n: number | bigint

        The non-negative integer or bigint representing the position.

      Returns bigint

      The n-th Fibonacci number as a BigInt.

      fibonacci(10); // 55n
      fibonacci(100n); // 354224848179261915075n

      If n is negative or not an integer.

      1.2.0