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.
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