Ad

A factorial is a number that has been multiplied by each number preceding it. In this exercise, use recursion to get the factorial of any given number. A recursive function is one that calls itself conditionally, for example a function that takes a number, prints it out, then calls itself with func_name(parameter_name - 1) to restart the process using a number one lower. Combine this with an if statement to avoid a recursion error, and you have a basic recursive function. Use this concept to find the factorial of any given number.

def factorial(n):
    # your code goes here
    return