Skip to content

Rad Pro: Random lottery number generator #157

Answered by Gissio
donavi-amoris asked this question in Q&A
Discussion options

You must be logged in to vote

No need for that. To generate a random number from 1 to 49, for example, you can use the following procedure:

  1. Generate two decimal RNG digits.
  2. If the digits fall within the range 1 to 49, keep it as your random number and stop.
  3. Otherwise, go back to step 1.

For example, suppose your RNG gives you these decimals digits: 1274361926759157. The first two digits are 12, so this is your first number. The second two digits are 74, so you discard them and go for the next two, which are 36, so there is your second number. And so on.

Do not reuse digits. It will skew probabilities.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Gissio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants