Skip to content

Commit 047dce9

Browse files
committed
adding kth factor algo
1 parent 253cca3 commit 047dce9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def kthFactor(self, n, k):
3+
"""
4+
:type n: int
5+
:type k: int
6+
:rtype: int
7+
"""
8+
9+
10+
for i in range(1, n+1):
11+
if n % i == 0:
12+
k -= 1
13+
if k == 0:
14+
return i
15+
16+
return -1
17+
18+
19+
20+

0 commit comments

Comments
 (0)