fork(3) download
  1. from math import floor, sqrt
  2.  
  3. def A006218(n):
  4. return 2 * sum(n // k for k in range(1, int(sqrt(n)) + 1)) - int(sqrt(n)) ** 2
  5.  
  6. def A061201(n):
  7. n3 = floor(n ** (1 / 3))
  8. s = 0
  9. for i in range(1, n3 + 1):
  10. s += 3 * A006218(int(n / i))
  11. for j in range(1, n3 + 1):
  12. s -= floor(n / (i * j))
  13. s += n3**3
  14. return s
  15.  
  16. for n in range(1, 10):
  17. print("{} = {}".format(n, A061201(n)))
  18.  
  19. # for n in range(1, 10):
  20. # print("{} = {}".format(n, A006218(n)))
  21.  
Success #stdin #stdout 0.02s 9260KB
stdin
Standard input is empty
stdout
1 = 3
2 = 8
3 = 13
4 = 21
5 = 26
6 = 37
7 = 42
8 = 74
9 = 82