Exercice 2
Ecrire un algorithme Python sous forme de fonction qui prends en paramètres un couple de deux entiers (p, q) et qui renvoie True si q est un diviseur de p et False si non
Solution
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
def is_div(p, q): # Tester si q est un diviseur de p if p%q == 0: return True else: return False # Exemple d'usage (p , q) = (12 , 4) print(is_div(p,q)) # output : True (p , q) = (16 , 5) print(is_div(p,q)) # output : False |
Younes Derfoufi
CRMEF OUJDA
![[App intégrée] 2025 Upgraded Vidéoprojecteur 1920 * 1080P FHD 4K Mini Projecteur Portable Dual Contrôle avec Souris Android TV WiFi 6 BT5.2 180° Rotation Compatible avec HDMI/TV Stick/USB](https://www.tresfacile.net/wp-content/uploads/2025/12/Videoprojecteur-1920-1080P-FHD-4K-Mini-Projecteur-Portable-Dual-Control-250x236.png)


1 thought on “Solution Exercice 2 : algorithme Python qui test si un entier est un diviseur d'un autre”