The concept of factorial
Factorial factor is an operation symbol invented by Keyston Kramp (1760–1826) in 1808.
Factorial factor is also a term in mathematics.
Factorial calculation method
Factorial factor refers to the required number obtained by multiplying 1 by 2 times 3 times 4.
For example, if the required number is 4, the factorial formula is 1×2×3×4, and the product is 24, that is, the factorial of 4. For example, if the required number is 6, the factorial formula is 1× 2× 3×…× 6, and the product is 720, which is the factorial of 6. For example, if the required number is n, the factorial formula is 1× 2× 3× …× n, and the product obtained is X, that is, the factorial of n. ..
Representation of factorial
When expressing factorial, use "!" To show. Such as the factorial of x, it is expressed as x!
[Edit this paragraph]
Factorial of numbers within 20
Because the product is very large, the factor is usually difficult to calculate.
The factorials from 0 to 20 are listed below:
0! = 1,
1! = 1,
2! =2,
3! =6,
4! =24,
5! = 120,
6! =720,
7! =5040,
8! =40320
9! =362880
10! =3628800
1 1! =399 16800
12! =47900 1600
13! =6227020800
14! =87 17829 1200
15! = 1307674368000
16! =20922789888000
17! =355687428096000
18! =6402373705728000
19! = 12 1645 100408832000
20! =2432902008 176640000
In addition, mathematicians define 0! = 1, so 0! = 1!
Definition range of factorial
Usually, the factorial is defined in the range of natural numbers, and there is no factorial for decimals, like 0.5! ,0.65! ,0.777! It's all wrong But sometimes we define the Gamma function as the factorial of non-integers, because when x is a positive integer n, the value of the Gamma function is the factorial of n- 1
Gamma function (gamma function)
γ (x) = ∫ e (-t) * t (x- 1) dt (the lower integral limit is zero and the upper integral limit is +∞) (x >; 0,- 1,-2,-3,……)
Using the knowledge of integral, we can prove that γ (x) = (x- 1) * γ (x- 1).
Therefore, when x is an integer n, γ (n) = (n-1) (n-2) ... = (n-1)!
So the gamma function actually extends the factorial.
[Computer Science]
Find the factorial of 365 with Ruby.
def ask factorial(num)factorial = 1;
1.step(num, 1){|i| factorial *=i}
return factorial end factorial = ask factorial(365)
Release factorial
Formula related to factorial
n! ~sqrt(2*pi*n)(n/e)^n
This formula is often used to calculate various limits related to factorial.