function Calculator::gcd
Returns the greatest common divisor of the two numbers.
This method can be overridden by the concrete implementation if the underlying library has built-in support for GCD calculations.
Return value
string The GCD, always positive, or zero if both arguments are zero.
1 method overrides Calculator::gcd()
- GmpCalculator::gcd in vendor/
brick/ math/ src/ Internal/ Calculator/ GmpCalculator.php - Returns the greatest common divisor of the two numbers.
File
-
vendor/
brick/ math/ src/ Internal/ Calculator.php, line 271
Class
- Calculator
- Performs basic operations on arbitrary size integers.
Namespace
Brick\Math\InternalCode
public function gcd(string $a, string $b) : string {
if ($a === '0') {
return $this->abs($b);
}
if ($b === '0') {
return $this->abs($a);
}
return $this->gcd($b, $this->divR($a, $b));
}