Tap here to switch tabs
Problem
Submissions

Problem: The kth Factor of n

med
30 min
Try to solve the The kth Factor of n problem.

Statement

Given two positive integers, n and k, a factor of n is any positive integer i such that n % i == 0.

Construct a list of all factors of n in ascending order and return the kthkth factor in this list. If n has fewer than k factors, return −1-1.

Constraints:

  • 1≤1 \leq k ≤\leq n ≤103\leq 10^3

⋮
Tap here to switch tabs
Problem
Submissions

Problem: The kth Factor of n

med
30 min
Try to solve the The kth Factor of n problem.

Statement

Given two positive integers, n and k, a factor of n is any positive integer i such that n % i == 0.

Construct a list of all factors of n in ascending order and return the kthkth factor in this list. If n has fewer than k factors, return −1-1.

Constraints:

  • 1≤1 \leq k ≤\leq n ≤103\leq 10^3