郑州大学——徐峰
public class Homework06 {
void test1(int a,int b){ int t ,i,m,n; m=a; n=b; if(a<b){ t=a; a=b; b=t; } while(a%b!=0){ t=a%b; a=b; b=t; } System.out.println("最大公约数是"+ b); for(i=n;i<=m*n;i++) if(i%m==0&&i%n==0){ System.out.println("最小公倍数为"+ i); break; }
public class Main06 {
public static void main(String[] args){ Homework06 x = new Homework06(); Scanner s = new Scanner(System.in); System.out.println("a="); int a=s.nextInt(); System.out.println("b="); int b=s.nextInt(); x.test1(a,b); }}