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

1557 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a recursive function that takes any integer n and prints the nth Fibonacci number.


Write a python function that takes a string as parameter and returns the character in the string with the most occurrences, along with the number of times this character occurs


What is the difference between DFS and BFS? Where can I apply each?


How do I use for loops in Python?


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:

© 2026 by IXL Learning