Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def func(n):
- sqrt = int(n ** 0.5)
- ans = 0
- ni = 0
- for i in range(1, sqrt): # how many times the current thing goes in n
- l = n // (i + 1) + 1
- r = n // i
- ans += (r - l + 1) * n - i * (r + 1 - l) * (l + r) // 2
- ni = i + 1
- for x in range(1, n // ni + 1):
- ans += n % x
- return ans
Advertisement
Add Comment
Please, Sign In to add comment