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
Answered by Niveda R. Python tutor

882 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

[Student query] Why do we import libraries/modules such as Numpy and Matplotlib into Python?


How do I check if a number is prime using a python program?


How do you write code to implement a recursive fibonacci algorithm?


Write a function that checks whether a number is prime or not.


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences