Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

The kth Factor of n

XPChallenge Points: 20
levelLevel: Medium

You are given two positive integers n and k.
A factor of n is defined as an integer i such that n % i == 0.
Return the kth factor of n (in ascending order).
If n has fewer than k factors, return -1.

Example 1:

Input: n = 12 k = 3

Output: 3

Example 2:

Input: n = 7 k = 2

Output: 7

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result