Java 计算两个数的最大公约数和最小公倍数

package com.MyJava;

import java.util.Scanner;

public class Test {
    
    
	public static void main(String[] args) {
    
    
		Scanner scan = new Scanner(System.in);

		System.out.print("输入第一个整数:");
		int x = scan.nextInt();
		System.out.print("输入第二个整数:");
		int y = scan.nextInt();

		outer: for (int i = x; i > 0; i--) {
    
    
			if (x % i == 0) {
    
    
				for (int j = y; j > 0; j--) {
    
    
					if (y % j == 0) {
    
    
						// System.out.println("第二个整数的约数为" + j);
						if (i == j) {
    
    
							System.out.println("最大公倍数为:" + j);
							System.out.println("最小公倍数为:" + x*y/j);
							break outer;
						}
					}
				}
			}
		}
	}
}