## How can you make a random number generator that chooses between the number 2 or 3. (not 1,2,3)

Hi I am working on a monty hall generator and in part of my code I need it to generate random number 2 or 3. It cannot be 1,2,3 but the computer needs to select between 2 or 3. Thanks!

I have tried `randomCarDoor = ( rand() % 3 ) + 1;`

but does not work.

`randomCarDoor = ( rand() % 3 ) + 1;`

It gives me the number `1,2,3`

but I just want `2`

and `3`

You can use the low order bit of the random value, but it is very risky as some pseudo-random number generators do not provide adequate dispersion on low order bits:

int two_or_three = 2 + rand() % 2;

A much better way is to use the magnitude of the random number which is specified as having a flat distribution:

int two_or_three = 2 + (rand() >= RAND_MAX / 2);

If you want numbers `1`

and `3`

, here is a simple solution for any pair:

int random_value = (rand() < RAND_MAX / 2) ? 1 : 3;

**Generating random whole numbers in JavaScript in a specific range ,** Math.random() returns a Number between 0 (inclusive) and 1 (exclusive). Let's choose a random number: This way, getRandomizer( 1, 6 ) will return either 1, 2, 3, 4, 5, or 6. NOTE: If you pass in a non-integer value or the greater number first you'll get undesirable behavior, but unless anyone requests it I am not going Generate one or more random numbers within a range that you define. Enter the minimum and maximum for the range you want and enter the number of numbers you want generated. You can also sort the generated numbers from lowest to highest, from highest to lowest, or choose to do not sort.

**RANDOM.ORG,** RANDOM.ORG offers true random numbers to anyone on the Internet. The randomness comes from atmospheric noise, which for many purposes is better than You can use this random number generator to pick a truly random number between any two numbers. For example, to get a random number between 1 and 10, including 10, enter 1 in the first field and 10 in the second, then press "Get Random Number". Our randomizer will pick a number from 1 through 10 at random.

This is not trivial using `rand()`

since a linear congruential generator typically alternates between odd and even numbers.

So one of the *worst* things you can do it to use a formula based on `rand() % 2`

.

In this *particular* case, I suggest you draw based on

n = rand();

and call it `1`

if `n < RAND_MAX / 2`

and `3`

otherwise, which you can do with

rand() < RAND_MAX / 2 ? 1 : 3

That might have adequate statistical properties - perhaps some unwanted autocorrelation - but probably no worse than `rand()`

itself.

**Random Number Generator,** I occasionally get feedback on this page about how it's “not random enough. E.g., if I ask for a random number between 1 and 1000, the possible results are: 1 900 numbers with 3 digits, 90 numbers with 2 digits and 9 numbers with 1 digit. Before we get into how to generate random numbers in Excel, there’s an important fact about these functions to take note of: A new random number is returned every time the worksheet is recalculated. This means that whenever you type in new data, your random numbers will change. Here’s what that looks like:

**Random Number Generator,** Use the Random Number Generator to create a list of random Random numbers are sets of digits (i.e., 0, 1, 2, 3, 4, 5, 6, 7, 8, 9) arranged in random order. Whether or not duplicate random numbers are permitted. Number Table consisting of 500 unique random numbers between 1 and 20,000. Let the random choice generator make a quick decision for you by picking a choice from a selection list of items you provide. It's a quick and easy decision maker. This tool is great for making a decision in trivial matters (should I continue building a mobile app or take a nap or etc).

**College Algebra,** 1. 1. 2. 3. 2. A good way to familiarize ourselves with a fact is to experiment with it. try some special cases to make sure there are no obvious counterexamples. thereby making it feasible to perform the experiment a large number of times. language or programmable calculator that has a random-number generator. To make the output less predictable, you need to seed the random-number generator. That’s done by using the srand () function. Like the rand () function, the srand () function requires the stdlib.h header, shown at Line 2 in Even More Randomness. The function requires an unsigned int value, seed, which is declared at Line 6.

**For All Practical Purposes: Mathematical Literacy in Today's World,** For permutations, some (but not all) scientific calculators have a command sequence, and The TI-84 + graphing calculator can find the number of permutations of 3 objects chosen Suppose that we want to choose a number at random between 0 and 1, allowing any Software random-number generators will do this. Number generator 2-22 quickly generates a random number between 2 and 22. You can generate as many random number as you like or changing the range of the numbers. Random Number Generator 1-22 Random Number Generator 3-22 Random Number Generator 2-23 Random Number Generator 2-21: Electrical Calculators Real Estate Calculators Accounting Calculators