9-line clean and simple Python solution


  • 0
    G
    def getFactors(self, n):
        """
        :type n: int
        :rtype: List[List[int]]
        """
        res = []
        
        for i in range(2, int(n**0.5) + 1):
            if n%i == 0:
                m = n//i
                for q in self.getFactors(m):
                    if q[0] >= i:
                        res.append([i] + q)
                res.append([i, m])
        return res

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.