Couple of problems: Here is the second

Here is the second part of my problem. I’m also having trouble converting this “while loop” into a “for loop”, any help ,again, would be greatly appreciated. Thanks!

[php]while ($count < 1000) {
$rolls = 1;
while (mt_rand(1, 6) != 6) {
$rolls++;
}
$total += $rolls;
$count++;
$max_rolls = max($rolls, $max_rolls);
}
$average_rolls = $total / $count;[/php]

[php]
$rolls = 1;
for($count = 0; $count<1000; $count++) {
while (mt_rand(1, 6) != 6) {
$rolls++;
}
$total += $rolls;
$max_rolls = max($rolls, $max_rolls);
}
$average_rolls = $total / $count;[/php]

Something like that, not really sure what you’re trying to accomplish with it. You could also convert that into a do/while loop.

Thank you so much!

Sponsor our Newsletter | Privacy Policy | Terms of Service