fork download
  1. import math
  2. import bisect
  3. numbers = list(range(1, 28123))
  4. abundant = set()
  5.  
  6. for n in numbers:
  7. m = 2
  8. divisorsum = 1
  9. while m <= math.sqrt(n):
  10. if n % m == 0:
  11. divisorsum += m + (n / m)
  12. m += 1
  13. if math.sqrt(n) % 1 == 0:
  14. divisorsum -= math.sqrt(n)
  15. if divisorsum > n:
  16. abundant.add(n)
  17. #print(sorted(abundant))
  18. nonabundantsum = 0
  19. for i in numbers:
  20. issumoftwoabundants = False
  21. for k in abundant:
  22. if k > i / 2:
  23. break
  24.  
  25. if i - k in abundant:
  26. issumoftwoabundants = True
  27. break
  28.  
  29. if not issumoftwoabundants:
  30. nonabundantsum += i
  31.  
  32. print(nonabundantsum)
Success #stdin #stdout 2.25s 10980KB
stdin
Standard input is empty
stdout
4179871