Skip to content

Instantly share code, notes, and snippets.

@pqcfox
Created January 27, 2015 04:22
Show Gist options
  • Save pqcfox/e6744dffe205cb8ee4dd to your computer and use it in GitHub Desktop.
Save pqcfox/e6744dffe205cb8ee4dd to your computer and use it in GitHub Desktop.
An exercise in my Number Theory class.
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