Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Repeating Decimals by bukebuer
def convert(a, b):
q = []
d = [str(a / b)]
a = a % b * 10
while a!=0 and a not in q:
q.append(a)
d.append(str(a / b))
a = a % b * 10
if len(d)==1:
return '%s.' % d[0]
elif a:
i = q.index(a)+1
return '%s.%s(%s)' % (d[0], ''.join(d[1:i]), ''.join(d[i:]))
else:
return '%s.%s' % (d[0], ''.join(d[1:]))
June 10, 2014
Comments: