Exercise 11
Write a program in Python that asks the user to enter an integer n and displays all the divisors of this number.
Solution
1 2 3 4 5 6 7 |
# ask the user to enter a value of n n = int(input("Type the value of integer n ")) # iterate through all integers less than or equal to n for i in range(1,n+1): # test if i is a divisor of n if(n%i==0): print("The number ",i," is a divisor of ",n) |
Younes Derfoufi
CRMEF OUJDA
1 thought on “Solution Exercise 11: algorithm python that find the divisors of an integer in python”