julian / ghz
Publicghz_state(n) prepares the n-qubit GHZ state:
A Hadamard on qubit 0 creates the superposition, then a chain of CNOTs
propagates it down the register.
int) — number of qubits.n = 0 → empty circuitn = 1 → single H (|+⟩ state)n = 2 → Bell staten ≥ 3 → GHZ state ┌───┐ ░ ┌─┐
q_0: ┤ H ├──■────────░─┤M├──────
└───┘┌─┴─┐ ░ └╥┘┌─┐
q_1: ─────┤ X ├──■───░──╫─┤M├───
└───┘┌─┴─┐ ░ ║ └╥┘┌─┐
q_2: ──────────┤ X ├─░──╫──╫─┤M├
└───┘ ░ ║ ║ └╥┘
meas: 3/═══════════════════╩══╩══╩═
0 1 2