求两个数45,27的最大公约数,为什么输出的不是9,而是45.
public class Main
{
public static void main(String[] args)
{
int a=45,b=27;
while(true){
if(a<b);
{int temp=a;
a=b;
b=temp;
}
int c=a%b;
a=b;
b=c;
if(c==0);{
break;
}
}
System.out.println(a);
}
}
public class Main
{
public static void main(String[] args)
{
int a=45,b=27;
while(true){
if(a<b);
{int temp=a;
a=b;
b=temp;
}
int c=a%b;
a=b;
b=c;
if(c==0);{
break;
}
}
System.out.println(a);
}
}