From charlesreid1

Problem Statement

ProjectEuler112.png

Analysis

This problem asks for the least positive integer such that the proportion of "bouncy" numbers up to is exactly 99%.

A number is bouncy if it is neither increasing (digits non-decreasing left-to-right, e.g., 13448) nor decreasing (digits non-increasing left-to-right, e.g., 99740).

Let be the count of bouncy numbers , and be the count of non-bouncy numbers .

The condition is .

Since , the condition becomes:

This means we seek the smallest such that .

A key consequence is that must be a multiple of 100.

Non-bouncy numbers are either increasing or decreasing.

Let be the count of increasing numbers and be the count of decreasing numbers .

Numbers with all identical digits (e.g., 555) are both increasing and decreasing; let their count be .

By inclusion-exclusion:

While calculating for arbitrary typically requires Digit Dynamic Programming, analytical formulas exist for :

Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle |D(10^{k}-1)|={\binom {k+10}{10}}-1-k}

These formulas show that the proportion of non-bouncy numbers drops below 1.3% for () and below 0.4% for (), indicating is likely greater than .

The computational strategy is:

1. Implement functions (likely using Digit DP) to compute accurately for any .

2. Search for the target by checking multiples of 100, starting from an estimated lower bound (e.g., ).

3. The first Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle N} found such that Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle NB(N) = N/100} is the solution.

Solution

Link to solution: https://git.charlesreid1.com/cs/euler/src/branch/master/java/Problem112.java

Flag