Skip to content

Instantly share code, notes, and snippets.

@mccricardo
Created November 12, 2013 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mccricardo/7440406 to your computer and use it in GitHub Desktop.
Save mccricardo/7440406 to your computer and use it in GitHub Desktop.
Problem 23 solution, using sets.
s = 0
abundant_numbers = set()
def get_divisors(number):
return [x for x in xrange(1, number/2 +1) if number % x == 0]
for i in xrange(1, 28123):
if sum(get_divisors(i)) > i:
abundant_numbers.add(i)
if not any((i-a in abundant_numbers) for a in abundant_numbers):
s += i
print s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment