Recursive Factorial Calculation

  • Share this:

Code introduction


Calculates the factorial of a given non-negative integer, which is defined as n! = n * (n-1) * (n-2) * ... * 1.


Technology Stack : Recursive call

Code Type : Recursive function

Code Difficulty : Intermediate


                
                    
def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)                
              
Tags: