Minimum excludant (source code)

= Minimum excludant
{title2=$\operatorname{mex}$}

= Mex
{synonym}

= Minimum excluded value
{synonym}

The <minimum excludant> of a finite <set> $S$ of <nonnegative integers> is the smallest <nonnegative integer> absent from $S$:
$$
\operatorname{mex}(S)=\min(\mathbb N\setminus S).
$$
For example, $\operatorname{mex}\{0,1,3\}=2$, while $\operatorname{mex}\varnothing=0$ and $\operatorname{mex}\{1,3\}=0$. It always exists and is at most $|S|$: the $|S|+1$ candidates $0,1,\ldots,|S|$ cannot all belong to a <set> of <cardinality> $|S|$.

In <Sprague-Grundy theory>, the <Grundy number> of a position in a finite acyclic <impartial game> is the <mex> of the values of its legal successor positions. The <minimum excludant> therefore converts the available moves into a reusable numerical description of a game position.