Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Repeating Decimals by gyahun_dash
from decimal import getcontext, Decimal
from re import sub
def convert(numer, denom):
prec = getcontext().prec = 4 * max(numer, denom)
quotient = str(Decimal(numer) / Decimal(denom))
if '.' not in quotient: return '{}.'.format(quotient)
if len(quotient) < prec: return quotient
return sub(r'(.+?)(.+?)\2\2.*', r'\1(\2)', quotient)
June 18, 2014