Skip to content

Instantly share code, notes, and snippets.

@mccricardo
Last active December 28, 2015 04:09
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/7439978 to your computer and use it in GitHub Desktop.
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
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