Let's reuse the `RandomBit` operation from the "Generate A Single Random Bit" exercise again.
We'll generate $N$ random bits by calling `RandomBit` operation $N$ times, and treat the result as a binary notation of the integer we're looking for.
Since the maximum value of the number written with $N$ bits is $2^N - 1$, we don't need to do any extra checks to ensure that the result is within the given range.
@[solution]({
"id": "random_numbers__random_n_bits_solution",
"codePath": "Solution.qs"
})microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
katas/content/random_numbers/random_n_bits/solution.md
8lines · modepreview