Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python recursion factorial

def factorial(n):

    assert type(n) == int, "Invalid input type"
    assert n >= 0, "Input must be non-negative"
    
    if n <= 1:
        return n
    else:
        return n*factorial(n-1)
 
PREVIOUS NEXT
Tagged: #python #recursion #factorial
ADD COMMENT
Topic
Name
6+4 =