The Q# user guide - Azure Quantum | Microsoft Learn

PHOTO EMBED

Fri May 12 2023 20:16:53 GMT+0000 (Coordinated Universal Time)

Saved by @mybusybeeadmin

@EntryPoint()
operation MeasureOneQubit() : Result {
    // Allocate a qubit, by default it is in zero state      
    use q = Qubit();  
    // We apply a Hadamard operation H to the state
    // It now has a 50% chance of being measured 0 or 1  
    H(q);      
    // Now we measure the qubit in Z-basis.
    let result = M(qubit);
    // We reset the qubit before releasing it.
    if result == One { X(qubit); }
    // Finally, we return the result of the measurement.
    return result;
    
}
content_copyCOPY

https://learn.microsoft.com/en-us/azure/quantum/user-guide/