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))

Answered by Niveda R. Python tutor

804 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Print "Hello World!" ten times without typing (or pasting) the print function more than once


What is the difference between DFS and BFS? Where can I apply each?


Why are negative indexes used?


What can be used to iterate through a list in python?


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences