Last active
December 28, 2015 04:09
-
-
Save mccricardo/7439978 to your computer and use it in GitHub Desktop.
Possible solution (using the wrong data structure for this approach) for Project Euler, Problem 23
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 = [] | |
def get_divisors(number): | |
return [x for x in xrange(1, number/2 +1) if number % x == 0] | |
for i in xrange(1, 28124): | |
if sum(get_divisors(i)) > i: | |
abundant_numbers.append(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