Problem · Math
Pth Factor
Learn this problemProblem statement
Given positive integers n and p, list all positive factors of n in ascending order.
Return the factor at 1-based position p. If n has fewer than p factors, return 0.
Function
pthFactor(n: long, p: long) → longExamples
Example 1
n = 20p = 3return = 4The factors of 20 are [1, 2, 4, 5, 10, 20]. The third factor is 4.
Constraints
1 ≤ n ≤ 10^151 ≤ p ≤ 10^9
More IBM problems
- Parent Process NumberOA · Seen Jul 2026
- Request Retry CountOA · Seen Jul 2026
- Count Strictly Increasing Subsequences of Length 3OA · Seen Jul 2026
- Maximum Requests in a Time WindowOA · Seen Jul 2026
- Query Type Frequency WindowOA · Seen Jul 2026
- Minimum Number of Non-Empty Disjoint SegmentsOA · Seen Jul 2026
- Spam Text ClassificationOA · Seen Jul 2026
- Count Ideal NumbersOA · Seen Jun 2026