MathsReadCompetitive mathematics
Algorithmic puzzle · integer answereasy25 min

Accelerated recurrence

Recursive Sequences

Let a_0=2, a_1=5, and a_n=(3*a_(n-1)+2*a_(n-2)) mod 1000003 for n>=2. Find a_50000.

Solve using mathematics, algorithms, or your own code offline. Submit only the final integer here—no program, expression, graph, or written proof.

Check your answer without signing in. Sign in to save your progress.

Accepted format: a whole number such as 42 or 123456789. No commas, formulas, or source code.

How to approach this problem

Keep the two most recent residues. Compute the new term from both before overwriting either; apply the modulus at each step. A two-by-two matrix can also represent the update.

Worked example with different values

For a₀=1, a₁=2 and aₙ=2aₙ₋₁+aₙ₋₂ modulo 7, the next two residues are 5 and 5.

Apply the same reasoning to the challenge. This example is a separate practice problem.

Learn the technique: Number theory: divisors, gcd and modular arithmetic

Report a question or explanation issue

Back to problems →