public class J5_14 {
public static void main(String[] args) {
// TODO Auto-generated method stub
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Enter number of n1 and n2:");
int n1 = input.nextInt();
int n2 = input.nextInt();
int d = 0;
if(n1 >n2)
d = n2;
else
d = n1;
int gcd =0;
do {
if(n1 %d ==0 && n2 %d ==0)
{
gcd =d;
break;
}
else
d--;
}while(d!=0);
System.out.println("n1 and n2 gcd is :"+gcd);
}
}
Java语言程序设计(基础篇)第十版 5.14
猜你喜欢
转载自blog.csdn.net/qq_41729287/article/details/83027466
今日推荐
周排行