Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In mathematics, the notation n! represents the factorial of the nonnegative inte

ID: 3630360 • Letter: I

Question

In mathematics, the notation n! represents the factorial of the nonnegative integer n. The factorial of n is the product of all the nonnegative integers from 1 up through n. For example:
7!=1x2x3x4x5x6x7=5040
and
4!=1x2x3x4=24
Design a python program that asks the user to enter a nonnegative integer and then displays the factorial of that number.
Also, display the output in the following form:
5!=1*2*3*4*5=120 To do this you will have to utilize a comma at the end of a print list. Program does not have to be modular just develop the logic without modular design.

Explanation / Answer

def factorial(n):

x = 1

for i in range(1, n + 1):

x = i * x

return x

num = raw_input( " enter integer ");

num = int(num);

print "%d! = %d" % (num, factorial(num))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote