Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- #----------------------------------------------------------------------------
- # Created by : Alain Van Kerckhoven
- # Created Date: 29 août 2022
- # Licence : GPL
- # Version : 1.0
- # ---------------------------------------------------------------------------
- """
- Un nombre parfait est un entier naturel égal à la somme de ses diviseurs stricts.
- 6 = 1+2+3
- """
- # ---------------------------------------------------------------------------
- nb_min = int(input("Commencer la recherche à : "))
- nb_max = int(input("Terminer la recherche à : "))
- print()
- print("Les nombres parfaits de",nb_min,"à",nb_max,"sont : ")
- for nb in range(nb_min, nb_max-1):
- somme = 0
- div = ""
- for i in range(1, nb - 1):
- if(nb % i == 0):
- somme = somme + i
- div = div + str(i) + " + " #liste des diviseurs
- if(somme == nb):
- div = div[:-3] # Enlever le dernier " + "
- print(str(nb)+" = "+div)
- print("=== Recherche terminée ===")
Advertisement
Add Comment
Please, Sign In to add comment