Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getPrimes(num):
- primes = {}
- i = 2
- while i * i <= num:
- while num % i == 0: num /= i; primes[i] = primes[i] + 1 if i in primes else 1
- i += 1
- if num != 1: primes[num] = primes[num] + 1 if i in primes else 1
- return primes
- def getDivisors(primes):
- dl = []
- cprimes = {}
- for p in primes:
- cprimes[p] = 0
- full = False;
- while not full:
- cd = 1
- for cp in cprimes:
- cd *= cp ** cprimes[cp]
- dl.append(cd)
- full = True
- for cp in cprimes:
- if full:
- if cprimes[cp] + 1 > primes[cp]:
- cprimes[cp] = 0
- full = True
- else:
- cprimes[cp] += 1
- full = False
- return dl
- def getDivSum(x):
- return sum(getDivisors(getPrimes(x))) - x
- s = 0
- for i in range(10000):
- if i != getDivSum(i) and i == getDivSum(getDivSum(i)):
- s += i
- #print(i)
- print(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement