要求:计算111111和1234567的最大公约数
pubilc class Ex1_1_24{private static int Euclid(int a, int b){int c = a % b;if(c == 0)return b;return Euclid(b, c);}pubilc static void main(String[] args){System.out.println(Euclid(1111111, 1234567)}}
要点:
a = n*b + c, 当c == 0时, b即为最大公约数,否则b代替a, c代替b.
