Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JesusCastroFernandez/0144cba91cc94c0ce509770aa8b4dc11 to your computer and use it in GitHub Desktop.
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
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