Posted by Betikci Boris on 02/01/08 07:13
On Jan 31, 8:56 pm, Fred <himse...@gmail.com> wrote:
> Hi guys,
>
> I was wondering how could i get a random number exemple between 1 and
> 100 but with n% of getting some value over a number x.
>
> Thanks a lot in advance.
>
> Fred
Here is the code ;)
for($i=1;$i<=100;$i++){
$rnum=rand(1,100);
if($rnum>x)
$bigx++;
else $smallx++;
$count++;
}
$ratio=$bigx/$count;
echo "Ratio of the created random numbers bigger than x is :" .
$ratio;
[Back to original message]
|