Skip to content

Instantly share code, notes, and snippets.

@Israel-Miles
Created February 20, 2022 23:03
Show Gist options
  • Save Israel-Miles/8275732b8ca6b75238cb43c00e6d2c99 to your computer and use it in GitHub Desktop.
Save Israel-Miles/8275732b8ca6b75238cb43c00e6d2c99 to your computer and use it in GitHub Desktop.
operation RandomBit () : Int {
// Allocate single qubit
use q = Qubit();
// Set qubit in superposition state with a Hadamard gate
H(q);
// Measuring state of qubit and return integer value of result
return (M(q) == Zero) ? 0 | 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment