Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Mr N
Lv 5
Mr N asked in Science & MathematicsMathematics · 6 years ago

If we are given a true random natural number generator, that generates natural numbers from 1 to 5, then how can we use it to...?

truly generate random natural numbers from 1 to 7?

1 Answer

Relevance
  • 6 years ago

    1 - 7 can be represented by 3 binary bits.

    Do this 3 times to get each bit.

    Take the random number 1-5 and if 1 or 2 the bit is 0

    If 3 ignore.

    if 4 or 5 the bit is 1.

    000 ignore

    001 = 1

    010 = 2

    011 = 3

    100 = 4

    101 = 5

    110 = 6

    111 = 7

Still have questions? Get your answers by asking now.