note 23022 added to function.gmp-gcd
| From: | x-empt-php dot net at ispep dot cx | Date: | Sun, 07 Jul 2002 03:16:36 +0000 |
| Subject: | note 23022 added to function.gmp-gcd | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32696@lists.php.net to get a copy of this message | ||
No need to compile gmp functions in just for the GCD function... use this one instead:
function GCD($num1, $num2) {
/* finds the greatest common factor between two numbers */
if ($num1 < $num2) {
$t = $num1;
$num1 = $num2;
$num2 = $t;
}
while ($t = ($num1 % $num2) != 0) {
$num1 = $num2;
$num2 = $t;
}
return $num2;
}
--
http://www.php.net/manual/en/function.gmp-gcd.php
http://master.php.net/manage/user-notes.php?action=edit+23022
http://master.php.net/manage/user-notes.php?action=delete+23022
http://master.php.net/manage/user-notes.php?action=reject+23022