how to compute the factorial of a number.

def factorial(n): fact = 1 for i in range(2,n+1): fact*=i; return factx=input("Enter a number :")print("The factorial of "+x+" is "+factorial(x))

NR

Related Python Mentoring answers

All answers ▸

Whats is the difference between a function and a procedure?


Which four data types are used in Python? Can you give an example of each?


With the help of Pandas and Numpy library create a DataFrame with the columns "Name", "Surname", "Age" and "Gender", create as many rows as you want. Print out the result.


How can you take a list of numbers and add 3 to every number in the list using only one line of code?