note 69188 deleted from function.gmp-gcd by bjori
| From: | bjori@php.net | Date: | Sat, 26 Aug 2006 11:17:23 +0000 |
| Subject: | note 69188 deleted from function.gmp-gcd by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-116340@lists.php.net to get a copy of this message | ||
Note Submitter: bigkm1 at gmail dot com
----
here is a more elegant solution using recursion, which removes the need for tmp variables.
<?php
function gcd($a,$b) {
return ($a % $b) ? gcd($b,$a % $b) : $b;
}
?>