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

1172 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How could I write a program to convert Km/h to m/s in python


How would you loop over every key and value in a python dictionary?


Write a program that computes the sum of all numbers up to a input number n


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


We're here to help

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

MyTutor is part of the IXL family of brands:

© 2026 by IXL Learning