By user42155


2008-12-12 18:20:57 8 Comments

How do I generate a random int value in a specific range?

I have tried the following, but those do not work:

Attempt 1:

randomNum = minimum + (int)(Math.random() * maximum);
// Bug: `randomNum` can be bigger than `maximum`.

Attempt 2:

Random rn = new Random();
int n = maximum - minimum + 1;
int i = rn.nextInt() % n;
randomNum =  minimum + i;
// Bug: `randomNum` can be smaller than `minimum`.

30 comments

@Lawakush Kurmi 2017-11-02 06:38:07

To generate a random number "in between two numbers", use the following code:

Random r = new Random();
int lowerBound = 1;
int upperBound = 11;
int result = r.nextInt(upperBound-lowerBound) + lowerBound;

This gives you a random number in between 1 (inclusive) and 11 (exclusive), so initialize the upperBound value by adding 1. For example, if you want to generate random number between 1 to 10 then initialize the upperBound number with 11 instead of 10.

@namezhouyu 2017-10-09 08:48:28

Random random = new Random();
int max = 10;
int min = 3;
int randomNum = random.nextInt(max) % (max - min + 1) + min;

@Peter Mortensen 2019-01-05 10:21:20

An explanation would be in order.

@Simo 2017-05-28 14:30:49

I use this:

 /**
   * @param min - The minimum.
   * @param max - The maximum.
   * @return A random double between these numbers (inclusive the minimum and maximum).
   */
 public static double getRandom(double min, double max) {
   return (Math.random() * (max+1-min)) + min;
 }

You can cast it to an Integer if you want.

@sokras 2017-07-20 07:38:51

This function produces the same number over and over again. In my case it was: 2147483647

@Maarten Bodewes 2018-04-23 21:26:54

Fail: you have a function that requires a double and then perform + 1? This certainly goes against the principle of least surprise. What happens if you use min = 0.1 and max = 0.2?

@Maarten Bodewes 2018-04-23 21:36:31

@sokras the method calls new Random (check the JavaDoc): "Creates a new random number generator. This constructor sets the seed of the random number generator to a value very likely to be distinct from any other invocation of this constructor." Very likely might just involve using the current time as seed. If that time uses milliseconds then current computers are fast enough to generate the same number. But besides that 2147483647 is Integer.MAX_VALUE; the output obviously depends on the input, which you haven't specified.

@Siddhartha Thota 2018-02-25 20:26:34

Say you want range between 0-9, 0 is minimum and 9 is maximum. The below function will print anything between 0 and 9. It's the same for all ranges.

public static void main(String[] args) {
    int b = randomNumberRange(0, 9);
    int d = randomNumberRange (100, 200);
    System.out.println("value of b is " + b);
    System.out.println("value of d is " + d);
}

public static int randomNumberRange(int min, int max) {
    int n = (max + 1 - min) + min;
    return (int) (Math.random() * n);
}

@monster 2018-08-14 12:25:54

Making the following change in Attempt 1 should do the work -

randomNum = minimum + (int)(Math.random() * (maximum - minimum) );

Check this for working code.

@Prakhar Nigam 2018-11-17 07:46:35

Use java.util for Random for general use.

You can define your minimum and maximum range to get those results.

Random rand=new Random();
rand.nextInt((max+1) - min) + min;

@Anjali Pavithra 2019-01-01 09:39:04

Below is a sample class which shows how to generate random integers within a specific range. Assign any value you want as the maximum value to the variable 'max' and assign any value you want as the minimum value to the variable 'min'.

public class RandomTestClass {

    public static void main(String[] args) {
        Random r = new Random();
        int max = 10;
        int min = 5;
        int x;
        x = r.nextInt(max) + min;
        System.out.println(x);
    }

}

@user2427 2008-12-12 18:28:35

int random = minimum + Double.valueOf(Math.random()*(maximum-minimum )).intValue();

Or take a look to RandomUtils from Apache Commons.

@zakmck 2015-01-30 09:27:17

That's useful, but beware a small flaw: method signatures are like: nextDouble(double startInclusive, double endInclusive), but if you look inside the methods, endInclusive should actually be endExclusive.

@Holger 2016-06-03 09:47:15

Double.valueOf(Math.random()*(maximum-minimun)).intValue() is quite an obfuscated (and inefficient) way to say (int)(Math.random()*(maximum-minimun))

@Hrishikesh Mishra 2016-12-26 05:14:23

Spelling mismatch for minimum return minimum + Double.valueOf(Math.random() * (maximum - minimum)).intValue();

@Greg Case 2008-12-12 18:25:27

In Java 1.7 or later, the standard way to do this is as follows:

import java.util.concurrent.ThreadLocalRandom;

// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
int randomNum = ThreadLocalRandom.current().nextInt(min, max + 1);

See the relevant JavaDoc. This approach has the advantage of not needing to explicitly initialize a java.util.Random instance, which can be a source of confusion and error if used inappropriately.

However, conversely there is no way to explicitly set the seed so it can be difficult to reproduce results in situations where that is useful such as testing or saving game states or similar. In those situations, the pre-Java 1.7 technique shown below can be used.

Before Java 1.7, the standard way to do this is as follows:

import java.util.Random;

/**
 * Returns a pseudo-random number between min and max, inclusive.
 * The difference between min and max can be at most
 * <code>Integer.MAX_VALUE - 1</code>.
 *
 * @param min Minimum value
 * @param max Maximum value.  Must be greater than min.
 * @return Integer between min and max, inclusive.
 * @see java.util.Random#nextInt(int)
 */
public static int randInt(int min, int max) {

    // NOTE: This will (intentionally) not run as written so that folks
    // copy-pasting have to think about how to initialize their
    // Random instance.  Initialization of the Random instance is outside
    // the main scope of the question, but some decent options are to have
    // a field that is initialized once and then re-used as needed or to
    // use ThreadLocalRandom (if using at least Java 1.7).
    // 
    // In particular, do NOT do 'Random rand = new Random()' here or you
    // will get not very good / not very random results.
    Random rand;

    // nextInt is normally exclusive of the top value,
    // so add 1 to make it inclusive
    int randomNum = rand.nextInt((max - min) + 1) + min;

    return randomNum;
}

See the relevant JavaDoc. In practice, the java.util.Random class is often preferable to java.lang.Math.random().

In particular, there is no need to reinvent the random integer generation wheel when there is a straightforward API within the standard library to accomplish the task.

@Daniel 2014-08-12 10:34:30

For calls where max value is Integer.MAX_VALUE it is possible to overflow ,resulting into a java.lang.IllegalArgumentException. You can try with : randInt(0, Integer.MAX_VALUE). Also, if nextInt((max-min) + 1) returns the most high value (quite rare, I assume) won't it overflow again( supposing min and max are high enough values)? How to deal with this kind of situations?

@momo 2015-02-23 06:26:46

This doesn't work for longs

@Moishe Lipsker 2015-06-17 17:18:28

@momo the RANDOM class supports nextLong. You could use that instead of nextInt for longs.

@momo 2015-06-17 18:42:57

@MoisheLipsker It must be that nextLong doesn't take a bound as nextInteger

@b1nary.atr0phy 2015-08-18 01:01:28

@momo Enlist help from the double. Just so: long val = ((long) (r.nextDouble() * (max - min))) + min

@momo 2015-08-18 12:01:45

Yes, I already do that, using the Math.random() which does that: public static long random(long min, long max) { return min + Math.round( Math.random() * ( (max - min) ) ); }

@leventov 2015-09-04 09:07:16

This snippet (that probably thousands of people copy) is BAD. It produce garbage. Just ThreadLocalRandom.current().nextInt(min, max).

@Greg Case 2015-09-11 01:57:18

@leventov ThreadLocalRandom was added to Java 2 1/2 years after this question was first asked. I've always been of the firm opinion that management of the Random instance is outside the scope of the question.

@Greg Case 2015-10-12 04:51:35

@AbhishekSingh The comments try to address this, but in more detail: nextInt(N) returns a number from 0 to N - 1, i.e. it will never return N as a result. In this case we want to include N in our possible range of values, so we add one: nextInt(N+1) => returns a number in the range 0 to N, inclusive of both 0 and N

@Lakatos Gyula 2016-04-14 20:20:24

Good luck testing classes that uses the ThreadLocalRandom.

@Webserveis 2016-10-03 19:55:05

In Android Random rand = new Random();

@Greg Case 2016-10-04 00:29:17

@Webserveis This is addressed in the comments in the example. Short version - you should not = new Random() for every call to the function, or your results will not be sufficiently random for many cases.

@Chit Khine 2017-03-07 08:02:38

Shouldn't you initialize the rand = new Random()?

@Greg Case 2017-03-13 03:09:44

@ChitKhine Not on each call to the function. The RNG algorithm under the hood of Random works well (enough for non-cryptographic applications) when generating successive random numbers. However, if the Random instance is re-created on each call, that means that instead of a proper RNG you're going to get "random" numbers based on whatever seed is chosen each time - often this is based on the system clock. This can give decidedly non-random results. Instead, you should consider instantiating your Random instance outside of method scope. The example code attempts to address this.

@user5365075 2018-02-20 13:04:55

Use ThreadLocalRandom.current().nextBytes(chunk); if you want to save yourself the new Random(). Thanks to a really popular question on generating random Integers in Java.

@Aman 2018-11-14 13:19:40

and if you're using for android java ThreadLocalRandom.current().nextInt(1, 100) it requires min API Level 21

@Alekya 2018-08-22 06:46:32

public static void main(String[] args) {

    Random ran = new Random();

    int min, max;
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter min range:");
    min = sc.nextInt();
    System.out.println("Enter max range:");
    max = sc.nextInt();
    int num = ran.nextInt(min);
    int num1 = ran.nextInt(max);
    System.out.println("Random Number between given range is " + num1);

}

@TJ_Fischer 2008-12-12 18:35:49

Note that this approach is more biased and less efficient than a nextInt approach, https://stackoverflow.com/a/738651/360211

One standard pattern for accomplishing this is:

Min + (int)(Math.random() * ((Max - Min) + 1))

The Java Math library function Math.random() generates a double value in the range [0,1). Notice this range does not include the 1.

In order to get a specific range of values first, you need to multiply by the magnitude of the range of values you want covered.

Math.random() * ( Max - Min )

This returns a value in the range [0,Max-Min), where 'Max-Min' is not included.

For example, if you want [5,10), you need to cover five integer values so you use

Math.random() * 5

This would return a value in the range [0,5), where 5 is not included.

Now you need to shift this range up to the range that you are targeting. You do this by adding the Min value.

Min + (Math.random() * (Max - Min))

You now will get a value in the range [Min,Max). Following our example, that means [5,10):

5 + (Math.random() * (10 - 5))

But, this still doesn't include Max and you are getting a double value. In order to get the Max value included, you need to add 1 to your range parameter (Max - Min) and then truncate the decimal part by casting to an int. This is accomplished via:

Min + (int)(Math.random() * ((Max - Min) + 1))

And there you have it. A random integer value in the range [Min,Max], or per the example [5,10]:

5 + (int)(Math.random() * ((10 - 5) + 1))

@Lilian A. Moraru 2012-02-23 23:26:34

The Sun documentation explicitly says that you should better use Random() if you need an int instead of Math.random() which produces a double.

@weston 2016-12-29 13:35:53

This is actually biased compared to nextInt methods stackoverflow.com/a/738651/360211

@vaquar khan 2018-05-31 15:16:34

import java.util.Random;

public class RandomSSNTest {

    public static void main(String args[]) {
        generateDummySSNNumber();
    }


    //831-33-6049
    public static void generateDummySSNNumber() {
        Random random = new Random();

        int id1 = random.nextInt(1000);//3
        int id2 = random.nextInt(100);//2
        int id3 = random.nextInt(10000);//4

        System.out.print((id1+"-"+id2+"-"+id3));
    }

}

@Peter Mortensen 2019-01-05 10:18:53

An explanation would be in order.

@Sanjeev Singh 2018-05-23 15:24:13

The following is another example using Random and forEach

int firstNum = 20;//Inclusive
int lastNum = 50;//Exclusive
int streamSize = 10;
Random num = new Random().ints(10, 20, 50).forEach(System.out::println);

@Oleksandr 2018-04-11 21:54:39

As of Java 7, you should no longer use Random. For most uses, the random number generator of choice is now ThreadLocalRandom.

For fork join pools and parallel streams, use SplittableRandom.

Joshua Bloch. Effective Java. Third Edition.

Starting from Java 8

For fork join pools and parallel streams, use SplittableRandom that is usually faster, has a better statistical independence and uniformity properties in comparison with Random.

To generate a random int in the range [0, 1_000]:

int n = new SplittableRandom().nextInt(0, 1_001);

To generate a random int[100] array of values in the range [0, 1_000]:

int[] a = new SplittableRandom().ints(100, 0, 1_001).parallel().toArray();

To return a Stream of random values:

IntStream stream = new SplittableRandom().ints(100, 0, 1_001);

@Johnbot 2018-07-20 06:29:12

Is there a reason why the example includes a .parallel()? It seems to me like generating a 100 random numbers would be too trivial to warrant parallelism.

@Oleksandr 2018-07-20 08:35:20

@Johnbot Thanks for comment, you are right. But, the main reason was to show an API (of course, the smart path is to measure performance before using parallel processing). By the way, for array of 1_000_000 elements, the parallel version was 2 times faster on my machine in comparison with sequential.

@Sunil Chawla 2014-08-03 03:07:54

Let us take an example.

Suppose I wish to generate a number between 5-10:

int max = 10;
int min = 5;
int diff = max - min;
Random rn = new Random();
int i = rn.nextInt(diff + 1);
i += min;
System.out.print("The Random Number is " + i);

Let us understand this...

Initialize max with highest value and min with the lowest value.

Now, we need to determine how many possible values can be obtained. For this example, it would be:

5, 6, 7, 8, 9, 10

So, count of this would be max - min + 1.

i.e. 10 - 5 + 1 = 6

The random number will generate a number between 0-5.

i.e. 0, 1, 2, 3, 4, 5

Adding the min value to the random number would produce:

5, 6, 7, 8, 9, 10

Hence we obtain the desired range.

@Mulalo Madida 2017-06-20 12:39:17

You can achieve that concisely in Java 8:

Random random = new Random();

int max = 10;
int min = 5;
int totalNumber = 10;

IntStream stream = random.ints(totalNumber, min, max);
stream.forEach(System.out::println);

@gerardw 2012-01-18 16:15:15

Another option is just using Apache Commons:

import org.apache.commons.math.random.RandomData;
import org.apache.commons.math.random.RandomDataImpl;

public void method() {
    RandomData randomData = new RandomDataImpl();
    int number = randomData.nextInt(5, 10);
    // ...
 }

@Joel Sjöstrand 2011-01-10 13:19:59

Forgive me for being fastidious, but the solution suggested by the majority, i.e., min + rng.nextInt(max - min + 1)), seems perilous due to the fact that:

  • rng.nextInt(n) cannot reach Integer.MAX_VALUE.
  • (max - min) may cause overflow when min is negative.

A foolproof solution would return correct results for any min <= max within [Integer.MIN_VALUE, Integer.MAX_VALUE]. Consider the following naive implementation:

int nextIntInRange(int min, int max, Random rng) {
   if (min > max) {
      throw new IllegalArgumentException("Cannot draw random int from invalid range [" + min + ", " + max + "].");
   }
   int diff = max - min;
   if (diff >= 0 && diff != Integer.MAX_VALUE) {
      return (min + rng.nextInt(diff + 1));
   }
   int i;
   do {
      i = rng.nextInt();
   } while (i < min || i > max);
   return i;
}

Although inefficient, note that the probability of success in the while loop will always be 50% or higher.

@mpkorstanje 2015-01-09 10:27:57

Why not throw an IllegalArgumentException when the difference = Integer.MAX_VALUE? Then you don't need the while loop.

@Christian Semrau 2015-05-06 19:27:30

@mpkorstanje This implementation is designed to work with any values of min <= max, even when their difference is equal to or even larger than MAX_VALUE. Running a loop until success is a common pattern in this case, to guarantee uniform distribution (if the underlying source of randomness is uniform). Random.nextInt(int) does it internally when the argument is not a power of 2.

@mpkorstanje 2015-05-07 10:36:57

Thanks for the explanation! Makes sense as the expected number of iterations is 2.

@jackson 2009-09-04 04:23:27

Use:

Random ran = new Random();
int x = ran.nextInt(6) + 5;

The integer x is now the random number that has a possible outcome of 5-10.

@Matt R 2009-01-08 15:04:42

The Math.Random class in Java is 0-based. So, if you write something like this:

Random rand = new Random();
int x = rand.nextInt(10);

x will be between 0-9 inclusive.

So, given the following array of 25 items, the code to generate a random number between 0 (the base of the array) and array.length would be:

String[] i = new String[25];
Random rand = new Random();
int index = 0;

index = rand.nextInt( i.length );

Since i.length will return 25, the nextInt( i.length ) will return a number between the range of 0-24. The other option is going with Math.Random which works in the same way.

index = (int) Math.floor(Math.random() * i.length);

For a better understanding, check out forum post Random Intervals (archive.org).

@Tapper7 2016-10-30 05:44:57

+1 for wayBackMachine archive screenshot link & your answer is still useful reference to get "random" ints w/in a range.

@AjahnCharles 2017-08-02 13:53:53

It baffles me why you instantiate index to 0.

@Matt R 2017-08-02 14:38:52

@CodeConfident The index variable will not affect the result of the random number. You can choose to initialize it any way you would like without having to worry about changing the outcome. Hope this helps.

@AjahnCharles 2017-08-02 14:41:09

Exactly... it's completely unused. I would initialise it directly to the rand: int index = rand.nextInt(i.Length);

@hexabunny 2015-03-12 22:44:28

Just a small modification of your first solution would suffice.

Random rand = new Random();
randomNum = minimum + rand.nextInt((maximum - minimum) + 1);

See more here for implementation of Random

@AxelH 2016-07-08 12:30:15

For minimum <= value < maximum, I did the same with Math : randomNum = minimum + (int)(Math.random() * (maximum-minimum)); but the casting isn't really nice to see ;)

@BMAM 2018-02-01 04:54:58

The below code generates a random number between 100,000 and 900,000. This code will generate six digit values. I'm using this code to generate a six-digit OTP.

Use import java.util.Random to use this random method.

import java.util.Random;

// Six digits random number generation for OTP
Random rnd = new Random();
long longregisterOTP = 100000 + rnd.nextInt(900000);
System.out.println(longregisterOTP);

@jatin3893 2012-10-27 08:17:26

I just generate a random number using Math.random() and multiply it by a big number, let's say 10000. So, I get a number between 0 to 10,000 and call this number i. Now, if I need numbers between (x, y), then do the following:

i = x + (i % (y - x));

So, all i's are numbers between x and y.

To remove the bias as pointed out in the comments, rather than multiplying it by 10000 (or the big number), multiply it by (y-x).

@Luke Taylor 2012-08-12 15:01:37

This methods might be convenient to use:

This method will return a random number between the provided min and max value:

public static int getRandomNumberBetween(int min, int max) {
    Random foo = new Random();
    int randomNumber = foo.nextInt(max - min) + min;
    if (randomNumber == min) {
        // Since the random number is between the min and max values, simply add 1
        return min + 1;
    } else {
        return randomNumber;
    }
}

and this method will return a random number from the provided min and max value (so the generated number could also be the min or max number):

public static int getRandomNumberFrom(int min, int max) {
    Random foo = new Random();
    int randomNumber = foo.nextInt((max + 1) - min) + min;

    return randomNumber;
}

@Maarten Bodewes 2017-03-01 21:26:35

// Since the random number is between the min and max values, simply add 1. Why? Doesn't min count? Usually the range is [min, max) where min is included and max is excluded. Wrong answer, voted down.

@Luke Taylor 2017-03-02 09:53:53

@MaartenBodewes +1 is added because getRandomNumberBetween generates a random number exclusive of the provided endpoints.

@Lii 2018-06-17 12:21:50

The number min + 1 will be twice as likely than the other number to be the result of getRandomNumberBetween!

@Hospes 2012-06-07 10:38:41

I found this example Generate random numbers :


This example generates random integers in a specific range.

import java.util.Random;

/** Generate random integers in a certain range. */
public final class RandomRange {

  public static final void main(String... aArgs){
    log("Generating random integers in the range 1..10.");

    int START = 1;
    int END = 10;
    Random random = new Random();
    for (int idx = 1; idx <= 10; ++idx){
      showRandomInteger(START, END, random);
    }

    log("Done.");
  }

  private static void showRandomInteger(int aStart, int aEnd, Random aRandom){
    if ( aStart > aEnd ) {
      throw new IllegalArgumentException("Start cannot exceed End.");
    }
    //get the range, casting to long to avoid overflow problems
    long range = (long)aEnd - (long)aStart + 1;
    // compute a fraction of the range, 0 <= frac < range
    long fraction = (long)(range * aRandom.nextDouble());
    int randomNumber =  (int)(fraction + aStart);    
    log("Generated : " + randomNumber);
  }

  private static void log(String aMessage){
    System.out.println(aMessage);
  }
} 

An example run of this class :

Generating random integers in the range 1..10.
Generated : 9
Generated : 3
Generated : 3
Generated : 9
Generated : 4
Generated : 1
Generated : 3
Generated : 9
Generated : 10
Generated : 10
Done.

@Michael Myers 2008-12-12 18:25:39

 rand.nextInt((max+1) - min) + min;

@ledlogic 2017-12-01 23:01:47

There is a library at https://sourceforge.net/projects/stochunit/ for handling selection of ranges.

StochIntegerSelector randomIntegerSelector = new StochIntegerSelector();
randomIntegerSelector.setMin(-1);
randomIntegerSelector.setMax(1);
Integer selectInteger = randomIntegerSelector.selectInteger();

It has edge inclusion/preclusion.

@Sam2016 2017-10-04 14:18:05

A simple way to generate n random numbers between a and b e.g a =90, b=100, n =20

Random r = new Random();
for(int i =0; i<20; i++){
    System.out.println(r.ints(90, 100).iterator().nextInt());
}

r.ints() returns an IntStream and has several useful methods, have look at its API.

@Alexis C. 2014-11-26 18:29:07

With they introduced the method ints(int randomNumberOrigin, int randomNumberBound) in the Random class.

For example if you want to generate five random integers (or a single one) in the range [0, 10], just do:

Random r = new Random();
int[] fiveRandomNumbers = r.ints(5, 0, 11).toArray();
int randomNumber = r.ints(1, 0, 11).findFirst().getAsInt();

The first parameter indicates just the size of the IntStream generated (which is the overloaded method of the one that produces an unlimited IntStream).

If you need to do multiple separate calls, you can create an infinite primitive iterator from the stream:

public final class IntRandomNumberGenerator {

    private PrimitiveIterator.OfInt randomIterator;

    /**
     * Initialize a new random number generator that generates
     * random numbers in the range [min, max]
     * @param min - the min value (inclusive)
     * @param max - the max value (inclusive)
     */
    public IntRandomNumberGenerator(int min, int max) {
        randomIterator = new Random().ints(min, max + 1).iterator();
    }

    /**
     * Returns a random number in the range (min, max)
     * @return a random number in the range (min, max)
     */
    public int nextInt() {
        return randomIterator.nextInt();
    }
}

You can also do it for double and long values.

Hope it helps! :)

@Naxos84 2018-02-26 07:13:43

I would suggest that you instantiate the randomIterator only once. See Greg Case comment on his own answer.

@Erfan Ahmed 2018-04-10 10:39:40

if you may, can you explain what is the significance of streamSize - the first param of this method given streamSize !=0. What is the difference if streamSize 1/2/n is given?

@cen 2018-05-11 12:31:06

Sweet solution, especially the stream class.

@Gihan Chathuranga 2017-08-12 14:10:39

This is the easy way to do this.

import java.util.Random;
class Example{
    public static void main(String args[]){
        /*-To test-
        for(int i = 1 ;i<20 ; i++){
            System.out.print(randomnumber()+",");
        }
        */

        int randomnumber = randomnumber();

    }

    public static int randomnumber(){
        Random rand = new Random();
        int randomNum = rand.nextInt(6) + 5;

        return randomNum;
    }
}

In there 5 is the starting point of random numbers. 6 is the range including number 5.

Related Questions

Sponsored Content

40 Answered Questions

[SOLVED] How do I convert a String to an int in Java?

58 Answered Questions

[SOLVED] How do I read / convert an InputStream into a String in Java?

60 Answered Questions

[SOLVED] Generate random string/characters in JavaScript

  • 2009-08-28 21:14:41
  • Tom Lehman
  • 952162 View
  • 1312 Score
  • 60 Answer
  • Tags:   javascript random

38 Answered Questions

[SOLVED] How do I efficiently iterate over each entry in a Java Map?

21 Answered Questions

[SOLVED] Generate random integers between 0 and 9

  • 2010-10-22 12:48:29
  • aneuryzm
  • 1478734 View
  • 1021 Score
  • 21 Answer
  • Tags:   python random integer

26 Answered Questions

[SOLVED] Generating random whole numbers in JavaScript in a specific range?

28 Answered Questions

[SOLVED] How do I generate a random int number in C#?

  • 2010-04-24 23:09:11
  • Rella
  • 1870092 View
  • 1574 Score
  • 28 Answer
  • Tags:   c# random

43 Answered Questions

[SOLVED] How to generate a random alpha-numeric string?

2 Answered Questions

[SOLVED] Getting random numbers in Java

  • 2011-05-04 17:52:46
  • Unknown user
  • 1692531 View
  • 325 Score
  • 2 Answer
  • Tags:   java random prng

18 Answered Questions

[SOLVED] Generate random number between two numbers in JavaScript

  • 2011-02-10 16:41:22
  • Mirgorod
  • 1112831 View
  • 1384 Score
  • 18 Answer
  • Tags:   javascript random

Sponsored Content