Tweakr
    Preparing search index...

    Function factorial

    • Computes the factorial of a non-negative integer using memoization and BigInt.

      Results are cached for performance and returned as BigInt for large values.

      Parameters

      • n: number | bigint

        The non-negative integer or bigint to compute the factorial of.

      Returns bigint

      The factorial of n as a BigInt.

      factorial(5); // 120n
      factorial(25n); // 15511210043330985984000000n

      If n is negative or not an integer.

      1.2.0