Pick a number between 1 to 5

After generating a random number using a computer program, it is still considered as a random number if the picked number is a part or the full one of the initial one. But if it was changed, then mathematicians do not accept it as a random number and they can call it a biased number.

But if you are developing a program for a simple task, this will not be a case to consider. But if you are developing a program to generate a random number for a valuable stuff such as lottery program, or gambling game, then your program will be rejected by the management if you are not consider about the above case.

So for those kind of people, here is my suggestion:

Generate a random number using Math.random() (say this n):

Now for [0,10) ==>  n*10 (i.e. one digit) and for[10,100) ==> n*100 (i.e., two digits) and so on. Here square bracket indicates that the boundary is inclusive and a round bracket indicates the boundary is exclusive.

Then remove the rest after the decimal point. (i.e., get the floor) - using Math.floor(). This can be done.

If you know how to read the random number table to pick a random number, you know the above process (multiplying by 1, 10, 100 and so on) does not violate the one that I was mentioned at the beginning (because it changes only the place of the decimal point).

Study the following example and develop it to your needs.

If you need a sample [0,9] then the floor of n10 is your answer and if you need [0,99] then the floor of n100 is your answer and so on.

Now let’s enter into your role:

You've asked for numbers in a specific range. (In this case you are biased among that range. By taking a number from [1,6] by roll a die, then you are biased into [1,6], but still it is a random number if and only if the die is unbiased.)

So consider your range ==> [78, 247] number of elements of the range = 247 - 78 + 1 = 170; (since both the boundaries are inclusive).

/* Method 1: */
    var i = 78, j = 247, k = 170, a = [], b = [], c, d, e, f, l = 0;
    for(; i <= j; i++){ a.push(i); }
    while(l < 170){
        c = Math.random()*100; c = Math.floor(c);
        d = Math.random()*100; d = Math.floor(d);
        b.push(a[c]); e = c + d;
        if((b.length != k) && (e < k)){  b.push(a[e]); }
        l = b.length;
    }
    console.log('Method 1:');
    console.log(b);

/* Method 2: */

    var a, b, c, d = [], l = 0;
    while(l < 170){
        a = Math.random()*100; a = Math.floor(a);
        b = Math.random()*100; b = Math.floor(b);
        c = a + b;
        if(c <= 247 || c >= 78){ d.push(c); }else{ d.push(a); }
        l = d.length;
    }
    console.log('Method 2:');
    console.log(d);

Note: In method one, first I created an array which contains numbers that you need and then randomly put them into another array.

In method two, generate numbers randomly and check those are in the range that you need. Then put it into an array. Here I generated two random numbers and used the total of them to maximize the speed of the program by minimizing the failure rate that obtaining a useful number. However, adding generated numbers will also give some biasedness. So I would recommend my first method to generate random numbers within a specific range.

In both methods, your console will show the result (press F12 in Chrome to open the console).

Share this Answer Link: help
Paste this link in email, text or social media.

Calculator Use

Generate one or more random numbers in your custom range from 0 to 10,000. Generate positive or negative random numbers with repeats or no repeats.

About Random Number Generators

There are two main types of random number generators: pseudo-random and true random.

A pseudo-random number generator (PRNG) is typically programmed using a randomizing math function to select a "random" number within a set range. These random number generators are pseudo-random because the computer program or algorithm may have unintended selection bias. In other words, randomness from a computer program is not necessarily an organic, truly random event.

A true random number generator (TRNG) relies on randomness from a physical event that is external to the computer and its operating system. Examples of such events are blips in atmospheric noise, or points at which a radioactive material decays. A true random number generator receives information from these types of unpredictable events to produce a truly random number.

This calculator uses a randomizing computer program to produce random numbers, so it is a pseudo-random number generator.

How to Generate Random Numbers

  1. What is your range? Set a minimum number and a maximum number. The random number(s) generated are selected from your range of numbers, with the min and max numbers included.
  2. How many numbers? Specify how many random numbers to generate.
  3. Allow repeats? If you choose No your random numbers will be unique and there is no chance of getting a duplicate number. If you choose Yes the random number generator may produce a duplicate number in your set of numbers.
  4. Sort numbers? You can decide not to sort your random numbers. You can also order your random numbers ascending, lowest to highest or descending, highest to lowest.

Do you need to include random numbers and letters in a random character set? See the CalculatorSoup® Random Number and Letter Set Generator.

Example: Generate a Random Number to Use as a PIN.

To generate a 6-digit PIN with or without duplicate digits choose the following settings:

  • Min = 0
  • Max = 9
  • Generate 6 numbers
  • Allow repeats = yes or no
  • Sort numbers = Do not sort

Do it: Generate a 6 digit PIN without duplicates

Example: Randomize a Set of Numbers

Say you have a group of 10 people represented by the numbers 1 to 10. You want to shuffle them into a random order of selection for an event.

Choose the following settings to randomize order of selection:

  • Min = 1
  • Max = 10
  • Generate 10 numbers
  • Allow repeats = no
  • Sort numbers = Do not sort

Do it: Randomize the order of a set of numbers, 1 to 10

Example: Randomly Choose One Number From a Range of Numbers

Say you want randomly select one number from 1 to 10, like drawing a number out of a hat.

Choose the following settings:

  • Min = 1
  • Max = 10
  • Generate 1 number
  • Allow repeats = no
  • Sort numbers = Do not sort

Do it: Random number generator 1 to 10

Also try: Random number generator 1 to 100

Example: Lottery Number Generator

You want to generate numbers for lottery tickets. You need to choose 5 numbers from a pool of 1 to 49 without duplicates.

Choose the following settings in the random number generator:

  • Min = 1
  • Max = 49
  • Generate 5 numbers
  • Allow Duplicates = no
  • Sort Numbers = low to high

Do it: Generate 5 lottery numbers from a range of 1 to 49

Follow CalculatorSoup:

Pick a number between 1 to 5
Pick a number between 1 to 5

What is the most picked number between 1 and 10?

Exploited in carnivals, the fact that given a choice of any number between 1 and 10, people will most often choose 3 or 7.

What is a number 1 6?

Writing 1/6 as a decimal using division method Here, the fraction is 1/6 which means we need to perform 1 ÷ 6. This gives the answer as 0.1666... So, 1/6 as a decimal is 0.16666...

What is the lucky number 1 to 10?

1, 3, 7, 9, 13, 15, 21, 25, 31, 33, 37, 43, 49, 51, 63, 67, 69, 73, 75, 79, 87, 93, 99, 105, 111, 115, 127, 129, 133, 135, 141, 151, 159, 163, 169, 171, 189, 193, 195, 201, 205, 211, 219, 223, 231, 235, 237, 241, 259, 261, 267, 273, 283, 285, 289, 297, 303, 307, 319, 321, 327, ... (sequence A000959 in the OEIS).

How do I get Google to pick a random number?

How to Use the RANDBETWEEN Function in Google Sheets.
Click on a cell in Google Sheets where you want to insert a random number..
Type in the function: =RANDBETWEEN(1, 10).
Press the Return key..
This should display any random integer between 1 and 10 in the same cell..

Whats a number between 1 and 100?

The whole number between 1 and 100 are 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74 ...