Skip to content

Instantly share code, notes, and snippets.

@hitsumabushi
Created August 12, 2012 02:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hitsumabushi/3329094 to your computer and use it in GitHub Desktop.
Dayly programing (Project Euler:#21)
#/usr/bin/python3
from math import sqrt
def d(n):
sum = 1
sq = int(sqrt(n))
for s in range(2, sq + 1):
if n % s == 0:
sum += s + int(n/s)
if sq == n:
sum -= s
return sum
Max = 10000
ans = 0
for x in range(2, Max):
y = d(x)
if y > x and d(y) == x:
ans += x + y
print(ans)
#=>31626
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment