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

866 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the difference between a FOR loop and WHILE loop and how do I write them?


Ask the user for a number and output the smallest divisor, bigger than one, for the inputted number. Output "Prime" if the number is a prime number.


What built-in types does python provide?


Write a function s(n) that will return a list of the first n squares.


We're here to help

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

© MyTutorWeb Ltd 2013–2024

Terms & Conditions|Privacy Policy