function x($a)
{
return rand(0, $a-1);
}
echo x(25);
<?PHP
function x($a)
{
$b = substr(abs(crc32($a)), 0, 1);
return ($a-$b > 0 ? $a-$b : 1);
}
echo x(46);
?>
function non_linear_decrease($input)
{
if ($input < 0 ) { return 0; }
$input_temp = $input;
$multiplier = 1;
while (($input_temp / 10) ) > 10) {
$multiplier = $multiplier * .9;
$input_temp = $input_temp / 10;
}
return $input * $multiplier;
}
<?php
// CONSTRAINED ASYMPTOTE ALGORITHM
// http://en.wikipedia.org/wiki/Asymptote
define("MINMIN", 0.0);
define("MAXMIN", 25.0); // NOT USED, PRESENT FOR ILLUSTRATION
define("MAXMAX", 10000.0);
define("MINPCT", 0.1);
define("MAXPCT", 0.999);
function asymptote($value) {
// NO VALUES BELOW MINIMUM THRESHOLD
if ($value <= MINMIN) {
return FALSE;
}
// COMPUTE A PERCENTAGE
$percent = $value / MAXMAX;
// CONSTRAIN MINIMUM
if ($percent < MINPCT) {
return $value - ( $value * MINPCT );
}
// CONSTRAIN MAXIMUM
if ($percent > MAXPCT) {
return $value - ( $value * MAXPCT );
}
// WITHIN CONSTRAINTS RETURN DIMINISHED VALUE
return $value - ( $value * $percent );
} // END function asymptote()
$kount = 1.0;
while ($kount < MAXMAX) {
$asymptote = asymptote($kount);
$pctg = 1.0 - $asymptote / $kount; // PERCENTAGE OF REDUCTION INCREASES AS VALUE INCREASES
echo "<br /> $kount $asymptote $pctg \n";
$kount++;
}
?>
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
15 Experts available now in Live!