Answer to Question #261391 in Python for TotterTats

Question #261391

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


1
Expert's answer
2021-11-06T01:42:09-0400
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?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog