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

897 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What are the main data structures that I can use in Python


Write a recursive function to return the nth Fibonacci number in Python


Create a program that generates prime numbers between two integer boundareis


Generate an array of integers from 0 to 99 and split it into two smaller arrays. Each smaller array will contain half of the original.


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