The kth Factor of n

Medium · Math & Number Theory · about 10 minutes

Asked at Google, Amazon, Microsoft, Bloomberg.

Return the k-th smallest factor of n, or -1 if n has fewer than k factors.