Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $twoHeads = 0;
- $total = 0;
- for($i = 0; $i < 1000000; ++$i) {
- $coinOneHeads = mt_rand(0, 1);
- $coinTwoHeads = mt_rand(0, 1);
- if( !$coinOneHeads && !$coinTwoHeads ) {
- continue;
- }
- ++$total;
- if( $coinOneHeads && $coinTwoHeads ) {
- ++$twoHeads;
- }
- }
- echo $twoHeads / $total;
Advertisement
Add Comment
Please, Sign In to add comment