Created
August 24, 2012 03:17
-
-
Save bhuber/3445093 to your computer and use it in GitHub Desktop.
pyler 26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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