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

913 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Give an example of a FOR loop


Manually implement a function that finds the smallest value in a list of integers and print it.


Whats is the difference between a function and a procedure?


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


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