matician - v2.0.0
    Preparing search index...

    Function factorial

    • Calculates the factorial of a non-negative integer n.

      The factorial of a number n is the product of all positive integers less than or equal to n.

      Parameters

      • n: number

        A non-negative integer.

      Returns number

      The factorial of n.

      Will throw an error if n is negative or not an integer.

      factorial(0); // returns 1
      factorial(5); // returns 120
      factorial(3); // returns 6