Created
May 26, 2023 11:10
-
-
Save JesusCastroFernandez/0144cba91cc94c0ce509770aa8b4dc11 to your computer and use it in GitHub Desktop.
Ejemplo de código cuántico en Q# que muestra cómo crear un circuito cuántico simple que consta de dos qubits y aplicar una puerta cuántica a cada uno de ellos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Microsoft.Quantum.Primitive; | |
operation SimpleQuantumProgram() : Unit { | |
// Allocate two qubits. | |
using (qubits = Qubit[2]) { | |
// Apply a Hadamard gate to the first qubit. | |
H(qubits[0]); | |
// Apply a CNOT gate between the first and second qubits. | |
CNOT(qubits[0], qubits[1]); | |
// Measure both qubits. | |
let (firstResult, secondResult) = (M(qubits[0]), M(qubits[1])); | |
// Print the results. | |
Message($"First result: {firstResult}"); | |
Message($"Second result: {secondResult}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment