Greatest Common Divisor

Find the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.

Code

Algorithms
function gcd($x, $y) { return $y === 0 ? $x : gcd($y, $x % $y); }
gcd($a, $b);

Parameters

First number

Second number

Server

More PHP Snippets