Build a quantum circuit which will calculate the sum of 3 classical bits eg. 1 + 0 + 1 or 1 + 1 + 1.
To create an algorithm that makes use of quantum logic gates, all the possible input states
need to be considered. The maximum sum possible is
The conditions that need to be satisfied are:
- If there is a
$\ket{100}$ or state with only one qubit in$\ket1$ state output01
. - If there is a
$\ket{110}$ or state with two qubits in$\ket1$ state output10
. - If there is a
$\ket{111}$ state output11
.
Firstly, concentrating on the first output qubit, it should only be flipped to
Then, to calculate the second output qubit a series of connected Toffoli or CCNOT gates can be used to achieve a
Finally, the circuit is measured, mapping qubits 3 and 4 onto classical bits 0 and 1, which represent the outcome of the addition, successfully calculating the sum of 3 bits using quantum logic gates.