Consider the recursive function for the calculation of a factorial.

def factorial(n):
if n == 1:
return n
else:
return n * factorial(n - 1)
print("The factorial of", 7, "is", factorial(7))
How could the program be modified to print the product of all the even numbers less than 7?

(1 point)
Responses

def factorial(n):
if n <= 1:
return 1
else:
if n % 2 != 0:
return n * factorial(n - 2)
else:
return factorial(n - 1)
print("The answer is", factorial(7))
def factorial(n): if n <= 1: return 1 else: if n % 2 != 0: return n * factorial(n - 2) else: return factorial(n - 1) print("The answer is", factorial(7))

def factorial(n):
if n == 1:
return n
else:
return n * factorial(n - 2)
print("The answer is", factorial(7))
def factorial(n): if n == 1: return n else: return n * factorial(n - 2) print("The answer is", factorial(7))

def factorial(n):
if n == 0:
return 1
else:
if n % 2 == 0:
return n * factorial(n - 2)
else:
return factorial(n - 1)
print("The answer is", factorial(7))
def factorial(n): if n == 0: return 1 else: if n % 2 == 0: return n * factorial(n - 2) else: return factorial(n - 1) print("The answer is", factorial(7))

def factorial(n):
if n <= 1:
return n
else:
return n * factorial(n - 2)
print("The answer is", factorial(7))
def factorial(n): if n <= 1: return n else: return n * factorial(n - 2) print("The answer is", factorial(7))
Skip to navigation

The correct answer is:

def factorial(n):
if n == 1:
return n
else:
return n * factorial(n - 2)
print("The answer is", factorial(7))