Reciprocal Cycles II

A unit fraction contains $1$ in the numerator. The decimal representation of the unit fractions with denominators $2$ to $10$ are given:
1/2 &= 0.5\\
1/3 &=0.(3)\\
1/4 &=0.25\\
1/5 &= 0.2\\
1/6 &= 0.1(6)\\
1/7 &= 0.(142857)\\
1/8 &= 0.125\\
1/9 &= 0.(1)\\
1/10 &= 0.1

Where $0.1(6)$ means $0.166666\cdots$, and has a $1$-digit recurring cycle. It can be seen that $1/7$ has a $6$-digit recurring cycle.

Unit fractions whose denominator has no other prime factors than $2$ and/or $5$ are not considered to have a recurring cycle.
We define the length of the recurring cycle of those unit fractions as $0$.

Let $L(n)$ denote the length of the recurring cycle of $1/n$.
You are given that $\sum L(n)$ for $3 \leq n \leq 1\,000\,000$ equals $55535191115$.

Find $\sum L(n)$ for $3 \leq n \leq 100\,000\,000$.

To find the solution to this problem, we need to calculate the length of the recurring cycle for each unit fraction with denominators from 3 to 100,000,000. We’ll use Python to implement the solution.

One way to find the length of the recurring cycle for a unit fraction is by implementing long division. We keep track of remainders encountered during the division process. Once we encounter a remainder that we have seen before, the recurring cycle ends.

Here’s the Python code to calculate the length of recurring cycle for each unit fraction:

def cycle_length(n):
remainder = 1
remainders = {}
position = 0

while remainder != 0 and remainder not in remainders:
remainders[remainder] = position
remainder = (remainder * 10) % n
position += 1

if remainder == 0:
return 0
return position – remainders[remainder]

total_length = 0
for n in range(3, 100000001):
total_length += cycle_length(n)

This code defines a function `cycle_length(n)` that takes in a denominator `n` and calculates the length of the recurring cycle in the decimal representation of 1/n.

The main part of the code initializes a variable `total_length` to keep track of the sum of lengths for all unit fractions. We then iterate over all denominators from 3 to 100,000,000 and add their corresponding cycle lengths to the `total_length` variable.

Finally, we print the value of `total_length`, which represents the sum of lengths of recurring cycles for the unit fractions.

Note that calculating the sum may take some time due to the large range of denominators. Make sure you have enough computational resources to run the code efficiently.

More Answers:
Kaprekar Constant
Titanic Sets
A Frog’s Trip

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded


Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!