LeetCodeThe kth Factor of nThe kth Factor of nMediumMathNumber TheorySolution export function kthFactor(n: number, k: number): number { let currentIndex = 0; for (let i = 1; i <= n; i++) { if (n % i === 0) { currentIndex += 1; } if (currentIndex === k) { return i; } } return -1; }LeetCodeThe kth Factor of nhttps://leetcode.com/problems/the-kth-factor-of-n