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

1236 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How do I use format python code?


Using the shared code editor, write a recursive function for calculating a factorial of an input parameter.


How do I define a function in Python?


Print "Hello World!" ten times without typing (or pasting) the print function more than once


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences