note 82282 added to function.gmp-gcd

From: Date: Thu, 03 Apr 2008 21:53:25 +0000
Subject: note 82282 added to function.gmp-gcd
Groups: php.notes 
Request: Send a blank email to php-notes+get-137909@lists.php.net to get a copy of this message
Try... function gcd($a, $b){ $b = ( $a == 0 )? 0 : $b; return ( $a % $b )? gcd($b, abs($a - $b)) : $b; } always returns positive number even if one or both numbers are negative (as per the gmp_gcd function) order agnostic, larger number can be $b or $a doesn't matter also, other examples here were failing when one of the numbers was 0 ---- Server IP: 69.147.83.197 Probable Submitter: 75.56.227.126 ---- Manual Page -- http://www.php.net/manual/en/function.gmp-gcd.php Edit -- https://master.php.net/note/edit/82282 Del: integrated -- https://master.php.net/note/delete/82282/integrated Del: useless -- https://master.php.net/note/delete/82282/useless Del: bad code -- https://master.php.net/note/delete/82282/bad+code Del: spam -- https://master.php.net/note/delete/82282/spam Del: non-english -- https://master.php.net/note/delete/82282/non-english Del: in docs -- https://master.php.net/note/delete/82282/in+docs Del: other reasons-- https://master.php.net/note/delete/82282 Reject -- https://master.php.net/note/reject/82282 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137909) next »