Created
February 19, 2015 04:23
-
-
Save paul-schwendenman/fa8ab19f723a16e9df3f 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
upper_bound = int(input("Upper bound: ")) | |
n = 1 | |
while n <= upper_bound: | |
factors = [] | |
i = 1 | |
while i < n: | |
if n % i == 0: | |
factors.append(i) | |
i += 1 | |
if sum(factors) == n: | |
print(n) | |
n += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment