Leetcode 1585 Solution
This article provides solution to leetcode question 1585 (the-kth-factor-of-n)
Access this page by simply typing in "lcs 1585" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/the-kth-factor-of-n
Solution
class Solution:
def kthFactor(self, n: int, k: int) -> int:
i = 1
cnt = 0
while i <= n:
if n % i == 0:
cnt += 1
if cnt == k:
return i
i += 1
return -1