strlen($y)) while(strlen($y)$x ".($add?'+':'-')." $y = $out
"; return $out; } function prime($p) { $s = 10; for($j=1; $j<=$s; $j++) { $a = bigRand(rand(1, strlen($p)-1)); if(bcmod($p, $a) == '0') return false; } return true; } function pow_mod($a, $b, $n) { $d = '1'; while(bccomp($b,'0')==1) { if(substr($b, -1) % 2 == 1){ $d = bcmod(bcmul($d, $a), $n); $b=bcsub($b,'1'); } if(bccomp($b,'0')=='1'){ $d = bcmod(bcmul($d, $d), $n); $b=bcdiv($b,'2'); } } return $d; } function bigRand($digits) { $result = ''; for($i=0; $i<$digits; $i++) $result .= rand(0,9); return $result; } ?>