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

516 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Use recursion to print all the sublists of a given list


What's the difference between a local and a global variable?


Write a function that takes the input of two numbers, and outputs the greater value.


Write a recursive function that takes any integer n and prints the nth Fibonacci number.


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–2024

Terms & Conditions|Privacy Policy