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 !
-
Apprendre à coder en python grâce à ChatGPT
€ 9,00 Acheter le livre -
AILKIN 2024 est un amplificateur WiFi ultra-performant, avec 1200 Mbps, double bande 5 GHz et 2,4 GHz, et 4 antennes puissantes, compatible avec tous les réseaux.
€ 31,00 Acheter le produit -
Python coding: Black Hat for Python Hackers and Pentesters
€ 37,00 Buy Now
1 thought on “Solution Exercise 11: algorithm python that find the divisors of an integer in python”