circuits / quantum-counting

Quantum Counting

FEATURED

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

quantumcomputer.dev
openqasm3q7 gatesdepth 40 views0 saves0 forks0 downloads

Source Code

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c[2];
// Counting qubit + search space
h q[0]; h q[1]; h q[2];
// Grover oracle
cz q[1],q[2];
// Controlled Grover iteration
ch q[0],q[1];
ch q[0],q[2];
// Inverse QFT on counting
h q[0];
measure q[0] -> c[0];
measure q[1] -> c[1];

Cite this circuit

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