microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.18.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

samples/getting_started/QuantumHelloWorld.qs

20lines · modeblame

c97c05a1DmitryVasilevsky1 years ago1/// # 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).
10Message("Hello world!");
11
12// Allocate a qubit. Qubit is in |0〉 state after allocation.
13use 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.
17MResetZ(qubit)
18
19// Note, that `qubit` is automatically deallocated at the end of the block.
20}