Write a program that asks the user for an integer greater than 0 and then use a for-loop to
calculate the factorial of that positive integer.
Modify your program so that the output looks like the following:
Example: 5! = 5 x 4 x 3 x 2 x 1 = 120
n = int(input()) res = f"{n}! = {n} " f = n for i in range(n-1, 0, -1): f *= i res += f"x {i} " res += f"= {f}" print(res)
Need a fast expert's response?
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments