Chrome Extension

Calculate the factorial of a number using python code

A recursive function is the best way to calculate the factorial of a number using Python.
def factorial(x):
    if x == 1:
        return 1
    else:
        return (x * factorial(x-1))

num = 4
print("The factorial of", num, "is", factorial(num))
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Was this helpful?
0 Comments
Join Devsheet Ask a Question