I'm trying to generate a list of 10 random numbers. I have some ranges like:
- 0 to 9
- 10 to 99
- 100 to 999
- 1000 to 9999
- 10000 to 99999
- 100000 to 999999.
If I generate a random number in a (min, max) range where min = 0
and max = 999999
with this code
import 'dart:math';
final _random = new Random();
int next(int min, int max) => min + _random.nextInt(max - min);
a number between 100000 and 999999 is more likely to be generated than a number between 0 and 9.
I would like to generate 10 random numbers in the given ranges with equal probability for each range.
Aucun commentaire:
Enregistrer un commentaire