Tool for computing factorials. Factorial n! is the product of all integer numbers (not zero) inferior or equal to n, it is symbolized by an exclamation point juxtaposed after the number.
Factorial - dCode
Tag(s) : Arithmetics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
Factorial of a number $ n $ is the product of the positive integers numbers (not null) less or equal to $ n $.
The usual notation to indicate a factorial is the exclamation mark positioned after the number. The factorial of $ n $ is noted $ n! $.
Factorial is calculated with a multiplication
$$ n!=\prod_{k=1}^n k = 1 \times 2 \times 3 \times \cdots \times n $$
Example: $$ 4! = 1 \times 2 \times 3 \times 4 = 24 $$
Example: The number of ways to sort a set of 52 cards is worth $ 52! = 1 \times 2 \times \dots \times 51 \times 52 = \\ 806581751709438785716606368564037\\66975289505440883277824000000000000 \\ \approx 8.0658 \times 10^{67} $$
Note that the factorial of zero is equal to one: $ 0! = 1 $
Example: Here are the values of the first factorials $$ 0! = 1 \\ 1! = 1 \\ 2! = 2 \\ 3! = 6 \\ 4! = 24 \\ 5! = 120 \\ 6! = 720 \\ 7! = 5040 \\ 8! = 40320 \\ 9! = 362880 \\ 10! = 3628800 $$
Euler-Gamma is an extension of the factorial function over the complex numbers set.
$$ \Gamma(n+1) = \int_0^{+\infty} t^n \exp(-t) \rm{d}t $$
and the formula that links gamma to the factorial:
$$ \forall\,n \in \mathbb{N}, \; \Gamma(n+1)=n! $$
For computing the factorial equivalent of negative numbers, use the Gamma function.
Pour computing the factorial equivalent of fraction or decimal numbers, use the Gamma function.
The factorial algorithm with a loop:function fact(n) {
f = 1
if (n >= 2) {
for (i = 2 ; i < n; i++) {
f = f * i
}
}
return f
}
The recursive factorial algorithm: function fact(n) {
if (n <= 1)
return 1
else
return fact(n-1)*n
}
For large numbers, it is possible to estimate the value of $ n! $ with a good precision using the Stirling formula. $$ n!\sim\sqrt{2\pi n}\left(\frac{n}{e}\right)^n $$
To calculate the product of numbers between $ n $ and $ n + m $, use factorials:
$$ \prod_{i=0}^m (n+i) = n(n+1)(n+2)\cdots(n+m) = \frac{(n+m)!}{(n-1)!} $$
dCode retains ownership of the "Factorial" source code. Any algorithm for the "Factorial" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Factorial" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Factorial" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Factorial" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Factorial on dCode.fr [online website], retrieved on 2025-04-15,