Created
February 6, 2015 09:16
-
-
Save ssanin82/42af9ef3729e3b8c8134 to your computer and use it in GitHub Desktop.
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 get_cycle_len(num): | |
found_remainders = [0] * num | |
value = 1 | |
position = 0 | |
while not found_remainders[value] and value: | |
found_remainders[value] = position | |
value *= 10 | |
value %= num | |
position += 1 | |
return 0 if not value else position - found_remainders[value] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment