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

924 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

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


Whats is the difference between a function and a procedure?


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


Write a simple Python program that asks a user to input their age and name and then return the text: "Hi my name is *NAME*, and I am *AGE* years old."


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences