Factorial

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n.

Read full: wiki/factorialopen in new window

Time complexity

factorial: O(n!)
memoizedFactorial: O(n)

Import

import {factorial, memoizedFactorial} from "@raikuxq/alg-ds/lib/exports/algorithms";

API reference

Factorial API: /api/algorithms/factorial

Example usage

import {memoizedFactorial} from "@raikuxq/alg-ds/lib/exports/algorithms";

memoizedFactorial(6); // 720
memoizedFactorial(10); // 3628800