# The kth Factor of n (Leetcode 1492)

Problem Link: <https://leetcode.com/problems/the-kth-factor-of-n/>

```python
class Solution:
    def kthFactor(self, n: int, k: int) -> int:
        
        f1=[]
        f2=[]
        
        for i in range(1, int(sqrt(n))+1):
            if(n%i==0):
                f1.append(i)
                f2.append(n//i)
                if(i==n//i):
                    f2.pop()
        
        f=f1+f2[::-1]
        if(len(f)<k):
            return -1
        return f[k-1]      
```
