Write a function that takes an integer n and return all possible combinations of its factors.
- You may assume that n is always positive.
- Factors should be greater than 1 and less than n.
1 | Input: 1 |
其实从上面看出,1, n都不能当作factors, 所以arr.size()至少是2: i.e. 递归终止的条件
1 | class Solution { |
也可以看出, factor combination实际上还是递归就完了,只不过-变成了/, 并没有必要先全排列所有的因子。