List All Factorizations of an Integer into Factors Greater Than 1
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Other
Overview: Return every way to write an integer as a product of factors greater than 1 and smaller than the number itself, each list in non-decreasing order and the lists sorted. Tests backtracking with a minimum-factor bound, pruning at the square root and avoiding duplicate orderings.
Constraints
- 1 <= n <= 10^7
Examples
Input: (1,)
Expected Output: []
Explanation: Minimum n = 1 has no factor in range, so the result is empty.
Input: (2,)
Expected Output: []
Explanation: n = 2 is the smallest prime and has no combination.
Hints
- Listing each combination in non-decreasing order gives it a single form, so reordered copies such as [6, 2] never appear.
- Once the smallest factor f of a combination is fixed, the other factors multiply to n / f and each is at least f.
- Try n = 12 by hand: [2, 2, 3] has to come before [2, 6] because the lists are compared element by element.