Write a recursive function to find the factorial of a number n.

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

MB

Related Python Mentoring answers

All answers ▸

What is the difference between a for loop and a while loop.


Manually implement a function that finds the smallest value in a list of integers and print it.


How does a for loop work in Python?


Write a function that takes a list of numbers as input, and outputs the average of the numbers. The function should catch any errors.