Created
May 11, 2016 13:35
-
-
Save alarsyo/6a866007c707681fe2b7d3c13fca6438 to your computer and use it in GitHub Desktop.
Perfect number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sumDivs(n,accu, i): | |
if i > (n//2): | |
return accu | |
elif n % i == 0: | |
print(i) | |
return sumDivs (n, accu + i , i+1) | |
else : | |
return sumDivs (n, accu, i+1) | |
x = int(input("give n ? ")) | |
print("les diviseurs de", x, "sont :") | |
if x < 1: | |
print("n must be > 1") | |
elif sumDivs(x, 0, 1) == x: | |
print(x, "is perfect") | |
else: | |
print(x, "isn't perfect") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment