主要用辗转相除法

public class Main{
	public static void main(String[] args) {		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a%b==0){
			System.out.println(a);
		}
		else if(b%a==0){
			System.out.println(b);
		}
		else if(a>b){
			int r;
			int c = a;
			int d = b;
			while(c%d!=0){
				r=c%d;
				c = d;
				d = r;
			}
			System.out.println(a*b/d);
		}
		else if(a<b){
			int r;
			int c = b;
			int d = a;
			while(c%d!=0){
				r=c%d;
				c = d;
				d = r;
			}
			System.out.println(a*b/d);
		}
	}
}