//题目:输入两个正整数m和n,求其最大公约数和最小公倍数。
package com.mumu.ready; import java.util.Scanner; public class Multiple { public static void main(String[] args) { Scanner can = new Scanner(System.in); System.out.println("Please input Integer m&n:"); int m = can.nextInt(); int n = can.nextInt(); int mn=m*n; if (m < n) { int temp = m; m = n; n = temp; } int temp = 1; while (temp != 0) { temp = m % n; m = n; n = temp; } System.out.println("最大公约数是:"+m); System.out.println("最小公倍数是:"+mn/m); } }