import java.util.Scanner; public class GCD_LCM{ public static void main( String args[]){ Scanner s = new Scanner (System.in); System.out.println("========计算两个数的最小公倍数========"); System.out.println("==============输入0 0结束============="); int i=1; while(true){ System.out.println("Case "+i+":\n请输入两个整数:"); int a = s.nextInt(); int b = s.nextInt(); if(a==0 && b==0) break; int m = gcd(a,b); int n = a*b/m; System.out.println("最小公倍数为:"+n+"\n"); i++; } System.out.println("===============输入结束==============="); } public static int gcd(int a, int b){ if (b != 0) return gcd(b,a%b); else return a; } }