Skip to content

Instantly share code, notes, and snippets.

@bhuber
Created Aug 24, 2012
Embed
What would you like to do?
pyler 26
def repeat(n):
rems = [0] * n
rem = 1
num = rem
result = ''
while True:
num *= 10
rems[rem] = 1
quot = num / n
if quot > 0:
result += str(quot)
rem = num % n
if rem == 0 or rems[rem] == 1:
break
num = rem
else:
result += '0'
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment