<?php
/*
The process of the Euclidean method
Divide two numbers to take the remainder to determine whether the remainder is zero,
is zero, the divisor is the current greatest common divisor,
is nonzero, the current divisor becomes dividend and the remainder becomes a divisor,
Then divide and take the remainder, then judge, until the residue is zero.
12 8
12% 8 more than 4
8% 4 more than 0
4 for greatest common divisor.
*/
$m = Isset ($_request[' m ')? $_request[' m ']: 12;
$n = isset ($_request[' n ')? $_request[' n ']: 4;
$num 1 = $m;
$num 2 = $n;
bo=
$mod = $m% $n;
$m = $n;
$n = $mod;
}while ($mod! = 0);
echo "$num 1, $num 2 of greatest common divisor is: $m";
This article is from the "Linux Warden" blog, so be sure to keep this source http://sswqzx.blog.51cto.com/2494644/1962393
Seeking greatest common divisor PHP by the method of dividing