# https://projecteuler.net/problem=26

# the length of the repeating
# decimal for (1 / n)
def reciprocal_cycle_length(n):
    quotients = []
    quotient = 1
    while quotient != 0 and quotient not in quotients:
        quotients.append(quotient)
        while quotient < n:
            quotient *= 10
        quotient = quotient % n
    if quotient == 0:
        return 0
    return len(quotients) - quotients.index(quotient)


longest_cycle_number = 1
longest_cycle_length = 0

for n in range(1, 1000):
    cycle_length = reciprocal_cycle_length(n)
    if cycle_length > longest_cycle_length:
        longest_cycle_length = cycle_length
        longest_cycle_number = n

print(longest_cycle_number)
