text: Find Recurring Sequence in a Fraction | C # program to find repeating sequence in a fraction ; This function returns repeating sequence of a fraction . If repeating sequence doesn 't  exits, then returns empty String ; Initialize result ; Create a map to store already seen remainders . Remainder is used as key and its position in result is stored as value . Note that we need position for cases like 1 / 6. In this case , the recurring sequence doesn 't  start from first remainder. ; Find first remainder ; Keep finding remainder until either remainder becomes 0 or repeats ; Store this remainder ; Multiply remainder with 10 ; Append rem / denr to result ; Update remainder ; Driver code
code: using System ; using System . Collections . Generic ; class GFG { static string fractionToDecimal ( int numr , int denr ) { string res = " " ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int rem = numr % denr ; while ( ( rem != 0 ) && ( ! mp . ContainsValue ( rem ) ) ) { mp [ rem ] = res . Length ; rem = rem * 10 ; int res_part = rem / denr ; res += res_part . ToString ( ) ; rem = rem % denr ; } if ( rem == 0 ) return " " ; else if ( mp . ContainsKey ( rem ) ) return res . Substring ( mp [ rem ] ) ; return " " ; } public static void Main ( string [ ] args ) { int numr = 50 , denr = 22 ; string res = fractionToDecimal ( numr , denr ) ; if ( res == " " ) Console . Write ( " No ▁ recurring ▁ sequence " ) ; else Console . Write ( " Recurring ▁ sequence ▁ is ▁ " + res ) ; } }