@@ -0,0 +1,1283 @@
+class Solution:%0A    # @param %7Binteger%7D numerator%0A    # @param %7Binteger%7D denominator%0A    # @return %7Bstring%7D%0A    def fractionToDecimal(self, numerator, denominator):%0A        result = %5B%5D%0A        numerators = %5B%5D%0A        def fraction(numer,denom):%0A            if numer in numerators:%0A                index = numerators.index(numer)%0A                i = 0%0A                n = len(result)%0A                while result%5Bi%5D != '.':%0A                    i += 1%0A                i+=1%0A                result.insert(index+i,'(')%0A                result.append(')')%0A                return %0A            else:%0A                numerators.append(numer)%0A                num = numer/denom%0A                rest = numer%25denom%0A                result.append(str(num))%0A                if rest ==0:%0A                    return%0A                else:%0A                    rest = rest*10%0A                    fraction(rest, denom)%0A        if numerator * denominator %3C 0:%0A            result.append('-')%0A        n = abs(numerator)/abs(denominator)%0A        r = abs(numerator)%25abs(denominator)%0A        result.append(str(n))%0A        if r == 0:%0A            return %22%22.join(result)%0A        else:%0A            result.append('.')%0A            r = r*10%0A            fraction(r,abs(denominator))%0A        return %22%22.join(result)%0A        

fraction to decimal