JAVA两数取余

	public static void main(String[] args) {
		int x,y,k,R1,R2,counter=0;
		Scanner sc = new Scanner(System.in);
		System.out.print("输入数值X:");
		x= sc.nextInt();
		System.out.print("输入数值y:");
		y= sc.nextInt();
		R1=x;
		R2=y;
		if (x<y) {
			k=x;
			x=y;
			y=k;//x对y取余,y赋值给x 余数赋值给y,直到y=0
		}
		while(x%y!=0) {
			counter++;
			k=x%y;
			x=y;
			y=k;			
	    }
		System.out.println("程序执行了"+counter+"次");
		System.out.println(R1+"与"+R2+"的最大公约是"+y);
		sc.close();
	}