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
Answered by Micah B. Python tutor

1330 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How do I define a function in Python?


How do you write code to implement a recursive fibonacci algorithm?


With the help of Pandas and Numpy library create a DataFrame with the columns "Name", "Surname", "Age" and "Gender", create as many rows as you want. Print out the result.


Sort a given input of lowercase letters alphabetically


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2025 by IXL Learning