classSolution{public:vector<vector<int>>getFactors(intn){vector<vector<int>>ans;dfs(n,2,{},ans);// The smallest factor is 2returnans;}private:voiddfs(intn,ints,vector<int>&&path,vector<vector<int>>&ans){if(n<=1){if(path.size()>1)ans.push_back(path);return;}for(inti=s;i<=n;++i)if(n%i==0){path.push_back(i);dfs(n/i,i,move(path),ans);path.pop_back();}}};
classSolution:defgetFactors(self,n:int)->List[List[int]]:ans=[]defdfs(n:int,s:int,path:List[int])->None:ifn<=1:iflen(path)>1:ans.append(path.copy())returnforiinrange(s,n+1):ifn%i==0:path.append(i)dfs(n//i,i,path)path.pop()dfs(n,2,[])# The smallest factor is 2returnans