Skip to content

Instantly share code, notes, and snippets.

@flxxyz
Created January 14, 2019 02:03
Show Gist options
  • Select an option

  • Save flxxyz/12b34708f253df93ad31ecbe817b9dff to your computer and use it in GitHub Desktop.

Select an option

Save flxxyz/12b34708f253df93ad31ecbe817b9dff to your computer and use it in GitHub Desktop.
简单中奖概率
<?php
$odds = 90; //概率
$success = 0;
$fail = 0;
$i = 0;
while ($i < 100) {
$rnd = mt_rand(0, 99);
if ($rnd < $odds) {
$success++;
} else {
$fail++;
}
$i++;
}
var_dump("中奖次数=" . $success . ", 没中次数=" . $fail);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment