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

def factorial(x): #base case if x == 1:    return 1 #recursive call  else:    return (x * factorial(x-1))Recursive algorithms are written using a strategy called divide and conquer. You try and break the problem up into a small repeatable sub-task.

CS
Answered by Conor S. Python tutor

1593 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a function that checks whether a number is prime or not.


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


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


Write a simple number guessing game, give the user 3 tries to guess a number between 1 and 10


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