= Solution
The printed word “even” conflicts with the displayed numbers: all ten listed <prime numbers> are odd, and $2$ is the only even <prime number>. The scan confirms that wording.<Functional programming, data structures and algorithms, procedural programming, and digital hardware examination paper by the University of Oxford (2005)>[Printed p. 5, Question 9(b), both occurrences of “even” and the final “including 2”]{ref} We first construct the detector for the explicitly listed numbers, then add $2$ as requested. The literal even-prime detector is also given below.
Let the five input <bits> be $A,B,C,D,E$ with value $16A+8B+4C+2D+E$. Every listed number has $E=1$. For that plane, the four-variable <Karnaugh map> is
|| $AB\backslash CD$
|| $00$
|| $01$
|| $11$
|| $10$
| $00$
| $0$
| $1$
| $1$
| $1$
| $01$
| $0$
| $1$
| $0$
| $1$
| $11$
| $0$
| $0$
| $1$
| $1$
| $10$
| $1$
| $1$
| $1$
| $0$
The entire $E=0$ plane is zero. Five valid groups in the displayed <Karnaugh map> give the product terms
$$
\overline A\,\overline C D,\quad
\overline A C\overline D,\quad
A\overline B\,\overline C,\quad
ABC,\quad
\overline B D.
$$
Including $E$, their accepted numbers are respectively $\{3,11\}$, $\{5,13\}$, $\{17,19\}$, $\{29,31\}$, and $\{3,7,19,23\}$. Their union is exactly the ten listed numbers. Hence an explicit <Boolean circuit> is: invert $A,B,C,D$ where needed, feed the five products into five <AND gates>, combine those outputs with an <OR gate>, and AND with $E$. Its output is
$$
\boxed{P_{\mathrm{odd}}=E\bigl(
\overline A\,\overline C D\lor
\overline A C\overline D\lor
A\overline B\,\overline C\lor
ABC\lor\overline B D\bigr).}
$$
Any gate with more than two inputs can be replaced by a tree of two-input gates. To include the exceptional <prime number> $2$, detect its exact <binary representation> $00010$ and add one OR branch:
$$
\boxed{P_{\mathrm{all}}=P_{\mathrm{odd}}\lor
\overline A\,\overline B\,\overline C D\overline E.}
$$
If “even prime” is read literally instead of following the listed numbers, the complete first detector is simply
$$
\boxed{P_{\mathrm{even}}=\overline A\,\overline B\,\overline C D\overline E.}
$$
All three formulas classify all $32$ possible inputs, including $0$ and $1$ as nonprime.
Back to article page