Input a comma-separated array and see the MEX (Minimum Excluded) computed step-by-step with frequency table and visual walkthrough.
MEX is the smallest non-negative integer missing from a set, and it turns up constantly in game theory and array problems because it is the exact quantity a Grundy number needs. The MEX Calculator computes it and, more usefully, shows the search that got there one candidate at a time.
Each step is a row: the value being tested, whether it appeared, and its frequency. Green rows are values found and skipped, and the single red row is the answer. That layout makes the definition hard to misremember, since the stopping condition is visible rather than implied.
A frequency table sits at the foot, and the input array is drawn as tiles with the value just below the MEX highlighted. Five example chips cover the shapes that catch people out. All of it is computed in the page as you type.
That array loads by default. The steps read 0 present, 1 present, 2 present, 3 present, then 4 absent, so the MEX is 4. Note that 5 is in the array and contributes nothing: MEX cares only about the unbroken run from 0 upward, so a value far above the gap is irrelevant. Press the Missing 0 chip for the counterpart, where 1, 2, 3, 4 has a MEX of 0 and the search ends on its first step.
0, 0, 1, 1, 3, whose MEX is 2, and the frequency table shows the repeats without them affecting the answer.-5, 0, 1 is treated as 0, 1 and returns 2. MEX is defined over non-negative integers, and the tool enforces that silently.5, 5, 5, 5, giving a MEX of 0 after a single step. A large value present many times still leaves 0 missing.Please enter valid non-negative integers separated by commas or spaces. Values may be separated by commas, spaces, or both at once.Input array (5 elements):
MEX Computation Steps
MEX of the array
4
The smallest non-negative integer not present in the array.
Frequency Table