MathsReadCompetitive mathematics
Algorithmic puzzle · integer answereasy25 min

Polynomial residues

Modular Arithmetic

How many integers n with 1 <= n <= 300000 satisfy n^2 + 3n + 7 congruent to 0 modulo 997?

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

Test one complete residue system, then count how often each qualifying residue appears in the specified inclusive interval. The polynomial depends only on the input residue.

Worked example with different values

For n² ≡ 1 (mod 5), residues 1 and 4 qualify. In 1 through 12, they occur at 1, 4, 6, 9 and 11.

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 →