After such a long time, finally know how to get along with the proof, before just remember, but not really understand, now write its proof, so that the next time you forget to look at. The greatest common divisor of a two-digit number is calculated.
To prove that the theorem is established, only the proof of gcd (A, b) = gcd (b, a% B) is required.
Proof: Make a% B = r, so a = K * B + R, so r = a-k * B, assuming that D is a number of conventions of a A, then D|a, d|b, (d|a means that D is evenly divisible A, that is, a can be divided by D), so A-k * B also must be divisible by D, that is D|r, d|. (a% B), so that D is also the number of conventions of B and (a% b), so that the number of conventions of a, B, and (A%B) is the same as the number of conventions, and their greatest common divisor must be the same, so gcd (A, b) = gcd (b, a% B);
So with this equation, basically even if the end, there is a step is how to find a specific number, when B equals 0 time can be, because the final recursive many or the original apartment number is the same, and finally there are 0, the two of their greatest common divisor is his own, that is, a, with the recursive code as follows
1 int gcd (intint b)2{3 return0 ? A:GCD (b, a% b)); 4 }
Euclidean algorithm (divided) proof