MathsReadCompetitive mathematics
Algorithmic puzzle · integer answereasy25 min

Two threes and a checksum

Digit Algorithms

How many integers from 1 through 200000 inclusive have the digit 3 occurring exactly twice in their usual decimal representation and a decimal digit sum divisible by 7?

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

Track both the number of target digit occurrences and the digit sum residue. A direct loop is feasible, or use digit DP with position, tight bound, occurrence count and remainder.

Worked example with different values

In 33 the digit 3 occurs twice and its sum is 6; in 303 it occurs twice too. Leading padding must not be treated as part of the original representation.

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 →