The following code is for a Python function to represent a recursive function to find the factorial of an integer

def factorial(x):
if x == 1:
return 1
else:
return (x * factorial(x-1))
num = 3

print("The factorial of", num, "is", factorial(num))
Which code reflects the recursive case?

(1 point)
Responses

else:
return (x * factorial(x - 1))
else: return (x * factorial(x - 1))

if x == 1:
return 1
if x == 1: return 1

print("The factorial of", num, "is", factorial(num))
print("The factorial of", num, "is", factorial(num))

num = 3
num = 3
Skip to navigation

page 14 of 14

1 answer

The code that reflects the recursive case is:

else:
        return (x * factorial(x - 1))

This part of the function calls factorial within itself with the argument x - 1, which is what makes the function recursive.