编辑代码

/*28许润涛*/
public class greatestCommonDivisor {
	public int gcd(int a, int b) {
		if(0 == a) {
			return b;
		}
		if(0 == b) {
			return a;
		}
		if(a > b) {
			int temp = 0;
			a = b;
			b = temp;
		}
		int c;
		if(b != 0) {
			for(c = a % b; c > 0; c = a % b) {
				a = b;
				b = c;
			}
		}
		return b;
	}
    public static void main(String[] args){
        greatestCommonDivisor g = new greatestCommonDivisor();
        int ret = g.gcd(1, 5);
        System.out.println(ret);
    }
}