Question: Question 3 4 pts Given a number n by user input, which of the following programs calculates the factorial of n? Hint: The factorial of
Question 3 4 pts Given a number n by user input, which of the following programs calculates the factorial of n?
Hint: The factorial of 5 is 5 * 4 * 3 * 2 * 1.
(There could be more than one correct answer.)
n = int(input())
fact = n while n >= 2: n -= 1 fact *= n
print(fact) n = int(input())
fact = 1 i = 1 while i <= n: fact *= i i += 1
print(fact) n = int(input())
fact = 1 while n >= 1: fact *= n n -= 1
print(fact) n = int(input())
fact = 1 while n >= 0: fact *= n n -= 1
print(fact * n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
