求最小公倍数
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
while((str=br.readLine())!=null){
String[] strArr = str.split(" ");
int n = Integer.parseInt(strArr[0]);
int m = Integer.parseInt(strArr[1]);
int j = m*n;
//最大公约数
while(n!=0){
int r = m%n;
m = n;
n = r;
}
int max = j/m;
System.out.println(max);
}
}
}
import java.util.*;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
while((str=br.readLine())!=null){
String[] strArr = str.split(" ");
int n = Integer.parseInt(strArr[0]);
int m = Integer.parseInt(strArr[1]);
int j = m*n;
//最大公约数
while(n!=0){
int r = m%n;
m = n;
n = r;
}
int max = j/m;
System.out.println(max);
}
}
}
全部评论
相关推荐
点赞 评论 收藏
分享
04-22 09:27
吉林大学 Java 点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 评论 收藏
分享