$x = 15; $y = 6; while ($x != $y) { if ($x > $y) { $x -= $y; } else { $y -= $x; } } echo $x;