protected static function AbstractAutomatedCrop::calculateGcd in Automated Crop 8
Calculate the greatest common denominator of two numbers.
Parameters
int $a: First number to check.
int $b: Second number to check.
Return value
int|null Greatest common denominator of $a and $b.
1 call to AbstractAutomatedCrop::calculateGcd()
- AbstractAutomatedCrop::setAspectRatio in src/
AbstractAutomatedCrop.php - Set the aspect ratio from plugin object.
File
- src/
AbstractAutomatedCrop.php, line 383
Class
- AbstractAutomatedCrop
- Provides a base class for each AutomatedCrop provider plugins.
Namespace
Drupal\automated_cropCode
protected static function calculateGcd($a, $b) {
if ($b > $a) {
$gcd = self::calculateGcd($b, $a);
}
else {
while ($b > 0) {
$t = $b;
$b = $a % $b;
$a = $t;
}
$gcd = $a;
}
return $gcd;
}