microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
alex/default-modern-std

Branches

Tags

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

Clone

HTTPS

Download ZIP

samples/python_interop/generating_n_random_bits/src/GenerateRandomNumbers.qs

15lines · modecode

1namespace GenerateRandom {
2 open Microsoft.Quantum.Arrays;
3 open Microsoft.Quantum.Convert;
4
5 operation GenerateRandomNumbers(nQubits : Int) : (Result[], Int) {
6 use qubits = Qubit[nQubits];
7
8 ApplyToEach(H, qubits);
9
10 let result = MResetEachZ(qubits);
11 let number = ResultArrayAsInt(Reversed(result));
12
13 return (result, number);
14 }
15}
16