| 1 | # This the main class for the solution |
| 2 | class Solution: # This class takes two integer n and k as input |
| 3 | def kthFactor(self, n: int, k: int) -> int: # Here n is the number and k is the kth factor. |
| 4 | ls = [] # Initialize the empty list |
| 5 | i = 1 |
| 6 | while(i<=n): # In this while loop we append all the factors of the number n |
| 7 | if n%i == 0: |
| 8 | ls.append(i) # Appending the number to the list. |
| 9 | i += 1 |
| 10 | try: # Returns the Kth factor if exist |
| 11 | return ls[k-1] |
| 12 | except: # else returns -1 |
| 13 | return -1 |
nothing calls this directly
no outgoing calls
no test coverage detected