MathsReadCompetitive mathematics
Algorithmic puzzle · integer answermedium50 min

Alternating parity milestone

Digit Algorithms

A positive integer is parity-alternating if its first (most significant) digit is odd and every following digit has parity opposite to the digit before it. What is the 500th smallest parity-alternating positive integer?

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

Count valid numbers by length, then enumerate or unrank lexicographically within a length. The allowed parity at each position is fixed; zero may appear only in later even positions.

Worked example with different values

For two digits, the first block is 10, 12, 14, 16, 18, followed by the block starting at 30.

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 →