Exercise 11 

Write a program in Python that asks the user to enter an integer n and display all the divisors of that number.

Solution

# Ask to type a value of the integer n
n = int(input("Type a value of the integer n "))
# run through all integers lower than n
for i in range(1,n+1):
# try if i is a divisor of n
if(n%i==0):
print("the number ",i," is a divisor for the integer ",n)
Younes Derfoufi
One thought on “Solution Exercise 11”

Leave a Reply