Skip to content

Commit

Permalink
fix: add measurement and nshots in Shor example (outdated from #1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Sep 9, 2024
1 parent 4f2314a commit 41a3f5c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/shor/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,9 @@ def quantum_order_finding_semiclassical(N, a):
circuit.add(gates.U1(q_reg, -angle))
circuit.add(gates.H(q_reg))
results.append(circuit.add(gates.M(q_reg, collapse=True)))
circuit.add(gates.M(q_reg))

circuit() # execute
circuit(nshots=1) # execute
s = sum(int(r.symbols[0].outcome()) * (2**i) for i, r in enumerate(results))
print(f"The quantum circuit measures s = {s}.\n")
return s
Expand Down

0 comments on commit 41a3f5c

Please sign in to comment.