give me a python code that takes 2 numbers as input, and multiplies their factorials
时间: 2024-03-02 07:49:21 浏览: 73
Here is the Python code that takes 2 numbers as input and multiplies their factorials:
```python
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
fact1 = factorial(num1)
fact2 = factorial(num2)
product = fact1 * fact2
print("The product of the factorials of", num1, "and", num2, "is", product)
```
In this code, we first define a function `factorial` that takes an integer `n` as input and returns the factorial of `n`. Then, we take two numbers as input from the user using the `input` function and convert them to integers using the `int` function.
Next, we compute the factorials of the two numbers using the `factorial` function and store them in the variables `fact1` and `fact2`. Finally, we calculate the product of the two factorials and print the result using the `print` function.
Note: The above code assumes that the input numbers are non-negative integers. If the input numbers can be negative or non-integer, the code needs to be modified accordingly.
阅读全文