microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
iadavis/3208-leak-fixes

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

samples/getting_started/QuantumHelloWorld.qs

20lines · modecode

1/// # Summary
2/// Quantum Hello World sample
3///
4/// # Description
5/// This is one of the simplest Q# programs that contains quantum part.
6/// This code prints the message then allocates a qubit and immediately measures it.
7/// Since the qubit starts in |0〉 state such measurement will always yield `Zero`.
8operation Main() : Result {
9 // Print the message (when running on a simulator).
10 Message("Hello world!");
11
12 // Allocate a qubit. Qubit is in |0〉 state after allocation.
13 use qubit = Qubit();
14
15 // Measure then reset the qubit. Last statement returns result from `Main`.
16 // Measurement result is `Zero` as the qubit is in |0〉 state.
17 MResetZ(qubit)
18
19 // Note, that `qubit` is automatically deallocated at the end of the block.
20}