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 ▸

What is the difference between a list and an array?


How would you loop over every key and value in a python dictionary?


What are docstrings and how do I use them to improve my code readability?


[Exam style] Python is an interpreted language. Explain what this means and how interpreted languages differ from compiled languages.