A trillion-step modular recurrence
Modular Recurrences
Define x₀=1 and xₙ₊₁=(3xₙ+5) mod 29, where mod 29 means the least nonnegative remainder. Find x_(10^12), the term after one trillion recurrence steps. For checks, x₁=8 and x₂=0. Submit one integer from 0 to 28.
Learning goal: Transform and exploit a modular recurrence to handle a very large index.
Look for the underlying structure rather than guessing the next number. Submit only the final integer; you can open hints below as needed.
Check your answer without signing in. Sign in to save your progress.
Hints
Hint 1
Try to remove the added 5 by subtracting a fixed point.
Hint 2
Find r such that r≡3r+5 (mod 29).
Hint 3
With r=12, the shifted sequence yₙ=xₙ−12 obeys yₙ₊₁≡3yₙ (mod 29). Use a power cycle.
Common mistake to avoid
Interpreting the index as 1012 rather than 10^12, or attempting direct trillion-step iteration.
How to approach this problem
Record each residue and its first step index. Once a state repeats, use the cycle length to reduce the remaining number of applications.
Worked example with different values
For x₀=0 and xₙ₊₁=(xₙ+2) mod 5, the states repeat every five steps: 0,2,4,1,3.
Apply the same reasoning to the challenge. This example is a separate practice problem.
Learn the technique: Sequence patterns: differences, recurrences and interleaving · Number theory: divisors, gcd and modular arithmetic