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

1583 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Give an example of a FOR loop


Write a program that takes a value x and then outputs x Fibonnaci numbers. E.g. if x=6 output would be 1 1 2 3 5 8


What can be used to iterate through a list in python?


Define a function that takes in the age of the user and adds it to an output sentence such as "You are ..... old".


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