Exercise 9.
Write a program in Python that asks the user to enter an integer n and display n!
Solution
1 2 3 4 5 6 7 8 |
# Ask the user to enter the value of the integer n n = int(input("Type a value of the integer n ")) # define and initialize an factorial of n facto = 1 for i in range(1,n+1): facto = facto*i print("Factorial of n is: ",n,"! =: ", facto) |
Younes Derfoufi
CRMEF OUJDA
1 thought on “Solution Exercise 9: python program that compute the factorial of an integer n”