Exercise 9 

Write a program in Python that asks the user to enter an integer n and display it the factorial n!

Solution

# Ask to type a value of the integer n
n = int(input("Type a value of the integer n "))
# define and initialize an auxiliary integer j
j = 1
for i in range(1,n+1):
j = j * i
print("The factorial the integer n is: n! = ", j)
Younes Derfoufi

Leave a Reply