Current location - Training Enrollment Network - Mathematics courses - How to calculate factorial
How to calculate factorial
Question 1: What is the formula of factorial? n! =n*(n- 1)!

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!

His principle is backward, such as finding the factorial of 10 = 10*9 (for later use! Then nine! =? ,9! =9*8! ,8! =8*7! ,7! =7*6! ,6! =6*5! ,5! =5*4! ,4! =4*3! ,

3! =3*2! ,2! =2* 1! What is the factorial of 1? Yes 1 1! = 1* 1, as stipulated by mathematicians, 0! = 1, so 0! = 1! Then calculate forward, the formula is n! (n! Factorial of current number) =n (current number) *(n- 1)! (The factorial of a number N- 1, which is one year younger than him, reverses the formula, only 1! It's 1, so we should start with 1, you know 3! You know, two! You should know 1! But it must be from 1! It's like pushing back when you start calculating. If the transfer algorithm can solve this formula with a function and call the nested quadratic function,) bring the number into the formula, 1! = 1* 1 2! =2* 1( 1! ) 3! =3*2(2! ) 4=4*6(3! ), if it is programming, how to solve the formula problem?

First, define the algorithm.

Algorithm, 1, define function, find factorial, define function fun, parameter value n, (#include

Long fun(int n) long is a long integer because 20! Very big, over one trillion.

(Mathematician Definition Mathematician Definition, 0! = 1, so 0! = 1! The factorial of 0 and 1 has no practical significance)

2. Judge the function body. If it is greater than 1, execute if(n >;; 1) (Back, this number is 10. Find it! , starting with the factorial value of 2, so the number of times the formula is executed is defined as 9. It is particularly important to note that here, the current first code execution has been calculated once. )

Find the n factorial of this number (formula is, n! =n*(n- 1)! And returns a value,

return(n *(fun(n- 1)); (This formula is that, first, this formula finds the factorial of 10, but finding the factorial of 10 requires the factorial of 9, and we don't know the factorial of 9, so we subtract 1 from/kloc-0, that is, n- 1 as a new factorial, and then call fun. Then execute n* the value it returns. In fact, this formula is the result of calling the fun function. The function value is the value returned by return, (n- 1) is a parameter, and so on ... nesting a value to call the fun function.

The value of n- 1 = 1,

Note: At this time, the fun () function has been run for 9 times, which is the first time. How many times have you called the fun function? Function of degree 8, therefore, n- 1 is executed for 9 times, and the value of order 2 can be obtained by calling n- 1= 1 and n=2.

Question 2: How to calculate factorial? The concept of factorial.

Is the factorial Keyston? Kaman (Christie Ankland, 1760? C 1826) was invented in 1808.

Factorial factor is also a term in mathematics.

[Edit this paragraph] Calculation method of factorial

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. 4 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. ..

[Edit this paragraph] Representation of factorial

When expressing factorial, use "!" To show. Such as the factorial of x, it is expressed as x!

Such as: n! = n×(n- 1)×(n-2)×(n-3)×n...× 1

Another representation of factorial: (2n- 1)! !

When n=2, 3! ! =3× 1=3

When n=3, 5! ! =5×3× 1= 15

When n=4, 7! ! =7×5×3× 1= 105

... (and so on)

[Edit this paragraph] factorial of numbers within 20.

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!

[Edit this paragraph] Define the 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 +∞) (x0,-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.

euler equation

x! =) = ∫-(ln (x)) ndx (the lower integral limit is zero and the upper integral limit is+1) (x > 0)

[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. ...& gt& gt

Question 3: What is the factorial of 2? That's two! ! What does this mean? How to calculate? Thank you. I think from the inside out:

The first floor: 2* 1=2

Second floor 2* 1=2

Question 4: The calculation method of factorial positive integer factorial refers to multiplying 1 by 2 times 3 times 4 to get the required number. 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. ..

Question 5: What is the formula of factorial? n! =n*(n- 1)!

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!

His principle is backward, such as finding the factorial of 10 = 10*9 (for later use! Then nine! =? ,9! =9*8! ,8! =8*7! ,7! =7*6! ,6! =6*5! ,5! =5*4! ,4! =4*3! ,

3! =3*2! ,2! =2* 1! What is the factorial of 1? Yes 1 1! = 1* 1, as stipulated by mathematicians, 0! = 1, so 0! = 1! Then calculate forward, the formula is n! (n! Factorial of current number) =n (current number) *(n- 1)! (The factorial of a number N- 1, which is one year younger than him, reverses the formula, only 1! It's 1, so we should start with 1, you know 3! You know, two! You should know 1! But it must be from 1! It's like pushing back when you start calculating. If the transfer algorithm can solve this formula with a function and call the nested quadratic function,) bring the number into the formula, 1! = 1* 1 2! =2* 1( 1! ) 3! =3*2(2! ) 4=4*6(3! ), if it is programming, how to solve the formula problem?

First, define the algorithm.

Algorithm, 1, define function, find factorial, define function fun, parameter value n, (#include

Long fun(int n) long is a long integer because 20! Very big, over one trillion.

(Mathematician Definition Mathematician Definition, 0! = 1, so 0! = 1! The factorial of 0 and 1 has no practical significance)

2. Judge the function body. If it is greater than 1, execute if(n >;; 1) (Back, this number is 10. Find it! , starting with the factorial value of 2, so the number of times the formula is executed is defined as 9. It is particularly important to note that here, the current first code execution has been calculated once. )

Find the n factorial of this number (formula is, n! =n*(n- 1)! And returns a value,

return(n *(fun(n- 1)); (This formula is that, first, this formula finds the factorial of 10, but finding the factorial of 10 requires the factorial of 9, and we don't know the factorial of 9, so we subtract 1 from/kloc-0, that is, n- 1 as a new factorial, and then call fun. Then execute n* the value it returns. In fact, this formula is the result of calling the fun function. The function value is the value returned by return, (n- 1) is a parameter, and so on ... nesting a value to call the fun function.

The value of n- 1 = 1,

Note: At this time, the fun () function has been run for 9 times, which is the first time. How many times have you called the fun function? Function of degree 8, therefore, n- 1 is executed for 9 times, and the value of order 2 can be obtained by calling n- 1= 1 and n=2.

Question 6: How to calculate factorial? The concept of factorial.

Is the factorial Keyston? Kaman (Christie Ankland, 1760? C 1826) was invented in 1808.

Factorial factor is also a term in mathematics.

[Edit this paragraph] Calculation method of factorial

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. 4 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. ..

[Edit this paragraph] Representation of factorial

When expressing factorial, use "!" To show. Such as the factorial of x, it is expressed as x!

Such as: n! = n×(n- 1)×(n-2)×(n-3)×n...× 1

Another representation of factorial: (2n- 1)! !

When n=2, 3! ! =3× 1=3

When n=3, 5! ! =5×3× 1= 15

When n=4, 7! ! =7×5×3× 1= 105

... (and so on)

[Edit this paragraph] factorial of numbers within 20.

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!

[Edit this paragraph] Define the 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 +∞) (x0,-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.

euler equation

x! =) = ∫-(ln (x)) ndx (the lower integral limit is zero and the upper integral limit is+1) (x > 0)

[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. ...& gt& gt

Question 7: Factorial positive integer factorial is calculated by multiplying 1 by 2 times 3 times 4 to get the required number. 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. ..

Question 8: How to calculate "factorial" factorial refers to multiplying 1 by 2 times 3 times 4 times the required number. 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 n, the factorial formula is 1× 2× 3× …× n, and the product obtained is X, that is, the factorial of n. ..

Question 9: How does C language find the sum of n factorial and main ()?

{ int s=0,a= 1,I;

for(I = 1; I