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 ▸

Demonstrate a recursive solution to calculate the factorial of a number


What is the outcome of the following code? print(2*[3,4,5])


Firstly, my question is not Python related, but maths A-level related. I don't know how to change that in my profile but I would like to only tutor maths GCSE and potentially A-level. My question: Integrate sin(x)^3 over x=0 and x=pi/2.


Explain how python programs are structured and give an example of how methods are initiated