Skip to content

Instantly share code, notes, and snippets.

@mavant
Created November 22, 2013 00:54
Show Gist options
  • Save mavant/7592816 to your computer and use it in GitHub Desktop.
Save mavant/7592816 to your computer and use it in GitHub Desktop.
Project Euler problem 21
import math
def d(n):
sum = 0
for i in range(1, int(math.sqrt(n)+1)):
if (n % i == 0):
sum += i
return sum
amicable = []
for a in range (2, 10000):
b = d(a)
db = d(b)
if (b != a and db == a):
amicable.append(a)
print (sum(amicable))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment