tests/php/common/src/random.php

#!/usr/local/bin/php -f
<!--
 $Id: random.php,v 1.2 2003/12/30 01:22:14 davidw Exp $
 http://www.bagley.org/~doug/shootout/
 END COMMENT -->
<?php
define("IM", 139968);
define("IA", 3877);
define("IC", 29573);

$LAST = 42;
function gen_random ($max) {
    global $LAST;
    return( ($max * ($LAST = ($LAST * IA + IC) % IM)) / IM );
}

$N = (($argc == 2) ? $argv[1] : 1) - 1;
while ($N--) {
    gen_random(100.0);
}

printf("%.9f\n", gen_random(100.0));
?>

Generated by GNU enscript 1.6.3.