dimanche 5 mai 2019

Scala Random Number Generator Not Producing Unique Random Numbers Between A Range

I have the following code to generate new random numbers

val start = 1
val end = 50000000
val rnd = new scala.util.Random

for (i < 1 to 25000000){
  val rnum = start + rnd.nextInt((end - start) + 1)

...
}

But this is producing duplicate random numbers now and again. Is this a bug or have I done something stupid?




Aucun commentaire:

Enregistrer un commentaire