circuits / quantum-counting

Quantum Counting

FEATURED

Combines Grover's oracle with QPE to count the number of solutions without knowing them.

quantumcomputer.dev
openqasm3q7 gatesdepth420 views0 saves0 forks0 downloads
1OPENQASM 2.0;
2include "qelib1.inc";
3qreg q[3];
4creg c[2];
5// Counting qubit + search space
6h q[0]; h q[1]; h q[2];
7// Grover oracle
8cz q[1],q[2];
9// Controlled Grover iteration
10ch q[0],q[1];
11ch q[0],q[2];
12// Inverse QFT on counting
13h q[0];
14measure q[0] -> c[0];
15measure q[1] -> c[1];

Cite this circuit

MIT
quantumcomputer.dev. "Quantum Counting". quantumcomputer.dev/circuits/quantum-counting. 2026.