Leetcode 1492: The kth Factor of n

In this Leetcode problem, we should return the kth factor of n, or -1 if such factor doesn’t exist.

Problem statement

This is pretty much brute force:

  • Test all integers from 1 to n
  • Count the number of factors current, when current = k return the current factor value