= Bouncy number
In <decimal representation>, a <bouncy number> is a <positive integer> whose <sequence> of <numerical digits> is neither <nondecreasing> nor <nonincreasing> from left to right. Equivalently, one adjacent pair strictly rises and another strictly falls. For example, $132$ is bouncy, while $124$ and $431$ are not. Repeated <numerical digits> are permitted by the weak order conditions: $112$ is <nondecreasing>.
A number satisfying both weak order conditions has every <numerical digit> equal, so the overlap consists exactly of the positive <repdigits>, such as $444$. If $I(N),D(N),R(N)$ count the <nondecreasing>, <nonincreasing> and <repdigit> positive <integers> at most $N$, respectively, <inclusion-exclusion> gives the count of <bouncy numbers> as
$$
N-I(N)-D(N)+R(N).
$$
This reduces counting the complement of two monotonicity conditions to counting those two simpler families and their explicit overlap.
Back to article page