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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!