$m = isset($_GET['m']) ? $_GET['m'] : 12;
$n = isset($_GET['n']) ? $_GET['n'] : 8;
//判断mn的大小
if($m>$n) {
$big = $m;
$small = $n;
} else {
$big = $n;
$small = $m;
}
//循环,从小的开始,到 1
for($d=$small; $d>=1; --$d) {
//判断是否可以整除
if($small%$d==0 && $big%$d==0) {
echo "$m, $n 的最大公约数为$d";
break;
}
}
转载于:https://blog.51cto.com/sswqzx/1962394