Clean python code

  • 0
    class Solution(object):
        def getFactors(self, n, start=2):
            r, sqrt = [], lambda x: int(math.sqrt(x))
            for i in xrange(start, sqrt(n) + 1):
                div, mod = divmod(n, i)
                if not mod:
                    r += [[i, div]]
                    if sqrt(div) >= i:
                        r += [[i] + p for p in self.getFactors(div, i)]
            return r

Log in to reply

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