package problems;

public class FractionToRecurringDecimal {
    public String fractionToDecimal(int numerator, int denominator) {
        if (denominator == 0)
            return "NULL";
        
        boolean sign = false;
        if (numerator < 0) {
            numerator = -numerator;
            sign = !sign;
        }
        if (denominator < 0) {
            denominator = -denominator;
            sign = !sign;
        }
        StringBuilder sb = new StringBuilder();
        if (sign)
            sb.append('-');
        
        if (numerator >= denominator) {
            sb.append(numerator / denominator);
            numerator %= denominator;
        }
        if (numerator == 0)
            return sb.toString();
        
        while ()
    }
    
    public static void main(String[] args) {
        FractionToRecurringDecimal fd = new FractionToRecurringDecimal();
        int num = 2;
        int de = 3;
        System.out.println(fd.fractionToDecimal(num, de));
    }
}

@@ -12,16 +12,65 @@
 blems;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 public c
@@ -251,42 +251,19 @@
     
-boolean sign = false;%0A        if (
+long num = 
 nume
@@ -268,34 +268,21 @@
 merator 
-%3C
+%3E
  0
-) %7B%0A          
  
+?
  numerat
@@ -284,19 +284,25 @@
 merator 
-=
+:
  -
+(long)
 numerato
@@ -316,48 +316,19 @@
     
-    sign = !sign;%0A        %7D%0A        if (
+long den = 
 deno
@@ -339,26 +339,13 @@
 tor 
-%3C
+%3E
  0
-) %7B%0A          
  
+?
  den
@@ -357,11 +357,17 @@
 tor 
-=
+:
  -
+(long)
 deno
@@ -374,26 +374,24 @@
 minator;
-%0A 
         
    sign 
@@ -386,34 +386,8 @@
     
-   sign = !sign;%0A        %7D
 %0A   
@@ -447,12 +447,41 @@
 if (
-sign
+1.0 * numerator / denominator %3C 0
 )%0A  
@@ -527,44 +527,114 @@
     
-if (numerator %3E= denominator) %7B%0A
+sb.append(num / den);%0A        num %25= den;%0A        if (num == 0)%0A            return sb.toString();    
     
+%0A
     
@@ -651,71 +651,180 @@
 end(
-numerator / denominator);%0A            numerator %25= denominator;
+'.');%0A        %0A        int i = sb.length();%0A        Map%3CLong, Integer%3E map = new HashMap%3CLong, Integer%3E();%0A        while (num %3E 0) %7B%0A            if (map.containsKey(num)) %7B
 %0A   
@@ -824,26 +824,24 @@
 ) %7B%0A        
-%7D%0A
         if (
@@ -841,27 +841,98 @@
    i
-f (numerator == 0)%0A
+nt t = map.get(num);%0A                sb.insert(t, '(');%0A                sb.append(')');%0A  
     
@@ -931,32 +931,34 @@
 ;%0A              
+  
 return sb.toStri
@@ -963,32 +963,37 @@
 ring();%0A        
+    %7D
 %0A        while (
@@ -989,16 +989,151 @@
     
-while 
+    map.put(num, i++);%0A            num *= 10;%0A            sb.append(num / den);%0A            num %25= den;%0A        %7D%0A        return sb.toString
 ()
+;
 %0A   
@@ -1281,9 +1281,10 @@
 m = 
-2
+-1
 ;%0A  
@@ -1302,9 +1302,19 @@
 e = 
-3
+-2147483648
 ;%0A  

Update Fraction to Recurring Decimal