Created
January 27, 2015 04:22
-
-
Save pqcfox/e6744dffe205cb8ee4dd to your computer and use it in GitHub Desktop.
An exercise in my Number Theory class.
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
highest = int(input("Enter a number: ")) | |
def perfect(n): | |
total = 0 | |
for k in range(1, n): | |
if n % k == 0: total += k | |
return total == n | |
for n in range(1, highest+1): | |
if perfect(n): | |
print(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment