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 ▸

Create a program that generates prime numbers between two integer boundareis


Use recursion to print all the sublists of a given list


h


Describe both For-loops and While-loops and explain how you can simulate the effect of a for loop with a while loop with an example.