:输入两个正整数m和n,求其最大公约数和最小公倍数。

import java.util.Scanner;


public class Divisor1 {
	//static int m;
	//static int n;
	int a,b;
	public static void main(String[]args){
		//输入两个数m,n
		System.out.println("请输入第一个数m=");
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		System.out.println("请输入第二个数n=");
		int n = in.nextInt();
		
		int r;
		while(n!=0){
			r = m%n;
			m = n;
			n = r;
		}
		System.out.println(m);
	}
	
}

 

你可能感兴趣的:(import,string,class,Java积累)