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 ▸

How would you get a piece of code to print the numbers 1 to 10


Give an example of a FOR loop


Write a simple number guessing game, give the user 3 tries to guess a number between 1 and 10


What is the difference between a for loop and a while loop?