Files
contests/26/main.py

8 lines
482 B
Python

# Find the number d < 1000 for which 1 / d has the longest recurring cycle
# in its decimal fraction part
# Observation: I first thought we only need to check prime numbers, but
# that is not the case. For example, 1/21 has a cycle of length 7, longer
# than both 3 and 7, but exactly the same as the cycles of 3 and 7 combined.
# But for 1/49 it has a cycle of length 42, so I don't think there is a
# clever way to deduce the length of the cycles without calculating them