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)

Answered by Micah B. Python tutor

1112 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

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


Implement a fibonacci function which calculates the nth number of the fibonacci sequence.


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


Generate an array of integers from 0 to 99 and split it into two smaller arrays. Each smaller array will contain half of the original.


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences