Created
November 12, 2013 23:01
-
-
Save mccricardo/7440406 to your computer and use it in GitHub Desktop.
Problem 23 solution, using sets.
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
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