function BigInteger::gcd
Returns the greatest common divisor of this number and the given one.
The GCD is always positive, unless both operands are zero, in which case it is zero.
Parameters
BigNumber|int|float|string $that The operand. Must be convertible to an integer number.:
File
-
vendor/
brick/ math/ src/ BigInteger.php, line 646
Class
- BigInteger
- An arbitrary-size integer.
Namespace
Brick\MathCode
public function gcd(BigNumber|int|float|string $that) : BigInteger {
$that = BigInteger::of($that);
if ($that->value === '0' && $this->value[0] !== '-') {
return $this;
}
if ($this->value === '0' && $that->value[0] !== '-') {
return $that;
}
$value = Calculator::get()->gcd($this->value, $that->value);
return new BigInteger($value);
}