Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def closestDivisors(self, num: int) -> List[int]:
- res = [1, num + 2]
- for i in range(1, 3):
- cand = num + i
- limit = math.floor(cand ** 0.5)
- for j in range(limit, 0, -1):
- if cand % j == 0 and abs(j - cand // j) < abs(res[1] - res[0]):
- res = [cand // j, j]
- break
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement