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
Acheter sur Très Facile !
-
Python pour le Lycée : Un Guide Complet en Seconde, Première et Terminale
€ 14,00 Acheter le livre -
Sécurité informatique : Apprendre l'attaque pour mieux se défendre (6e édition)
€ 54,00 Acheter le livre -
Apprendre l'intelligence artificielle avec Python : Recherche, optimisation, apprentissage
€ 32,00 Acheter le livre
1 thought on “Solution Exercise 11: algorithm python that find the divisors of an integer in python”