Code looks like this:

What I want to do? Want to make the probability of getting three identical numbers.

That is ($one == $two && $one == $three) will be possible with a probability of, for example, 80%

```
$one = rand(1, 6);
$two = rand(1, 6);
$three = rand(1, 6);
```

What I want to do? Want to make the probability of getting three identical numbers.

That is ($one == $two && $one == $three) will be possible with a probability of, for example, 80%

asked June 3rd 19 at 20:20

1 answer

answered on

Solution

Forehead:

rand() - gives a bad Rand, not use.

mt_rand () is better.

random_int() - gives a good random, but slower.

```
$one = rand(1, 6);
if (rand(1, 10) <= 8 ) {
$two = $three = $one;
} else {
$two = rand(1, 6);
$three = rand(1, 6);
}
```

rand() - gives a bad Rand, not use.

mt_rand () is better.

random_int() - gives a good random, but slower.

Find more questions by tags PHP