Respuesta :
Answer:
Following are code of factorial in python language
def factorial(n): # function
result=1 #variable
for x in range(2,n+1): #iterating the loop
result=result*x #storing result
return result #return result
for n in range(10): #iterating loop
print(n,factorial(n)) #print factorial
Output:
Following are the attachment of output
Explanation:
Missing information :
In the question the information is missing the code is missing which we have to correct it following are the code that are mention below.
def factorial(n): # function
result=1 #variable
for x in range( ): #iterating the loop
result= #storing result
return #return result
for n in range( ): #iterating loop
print(n,factorial(n)) #print factorial
Following are the description of code
- We have create a function factorial in this we have pass the one parameter i.e "n".
- In the for loop we have pass 2,n+1 which has been used to iterating the loop calculating factorial and string the result in the result variable
- In the main function we have pass the range on which we have to calculated the factorial
- Finally the print function will print the factorial .
Following are the attachment snip of code in the python language


By filling in the blanks to make the factorial function return the factorial of n, we have the following.
def factorial (n):
result = 1
for x in range(2, n+1):
result = result*x
return result
for n in range(10):
print(n,factorial(n))
The math module in Python includes a number series of mathematical operations that may be easily done using the module. The math . factorial() function computes the factorial of a given number.
To write the code perfectly and fill in the blanks:
- We created a math factorial function with n parameter
- This code is being passed through the iterating loop 2,n+1 for calculation.
- We string the result, perform the range, and print out the result using the print formula.
CODE:
def factorial (n):
result=1
for x in range(2, n+1):
result = result*x
return result
for n in range(10):
print(n,factorial(n))
RESULT:
0 1
1 1
2 2
3 6
4 24
5 120
6 720
7 5040
8 40320
9 362880
Therefore, we can conclude that we've understood how to write the factorial function code in python.
Learn more about python coding here:
https://brainly.com/question/1351889?referrer=searchResults
