Creating random numbers with quantum computing

This sample implements a quantum random number generator, a very simple application that is useful to learn how to write a first Q# program.

In the Q# code (Qrng.qs) you will find the Q# operation for extracting a random bit using quantum measurements over a qubit in superposition. For more information, you can take a look at the full tutorial.

You will also find a Q# operation that creates a random integer from 0 to a maximum integer by invoking several times the Q# operation for extracting a random bit.


Running the Sample

To run the sample, use the dotnet run command from your terminal.


  • Qrng.qs: Q# code implementing quantum operations for this sample.
  • Qrng.csproj: Main Q# project for the sample.