import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
for(int i=1; i<=b;i++){
if(a*i %b ==0){
System.out.println(a*i);
break;
}
}
}
} 找规律题,①如果a % b == 0 输出a ②如果b % a == 0 输出b。③找到MAth.max(a, b),把大的数从2开始乘,直到该数 % 较小数 == 0,该数即为最小公倍数。7.18
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int a = in.nextInt();
int b = in.nextInt();
if (a >= b && a % b == 0){
System.out.println(a);
}else if (a < b && b % a == 0){
System.out.println(b);
}else{
if (a > b){
int index = 2;
while((b * index) % a != 0){
index++;
}
System.out.println(b);
}else{
int index = 2;
while((a * index) % b != 0){
index++;
}
System.out.println(a * index);
}
}
}
}
} import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
int bigger = a > b ? a : b;
int smaller = a < b ? a : b;
for(int i = 1;; i++)
if((bigger * i) % smaller == 0){
System.out.print(bigger * i);
break;
}
}
} import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long a = in.nextLong();
Long b = in.nextLong();
System.out.println(lcm(Math.max(a,b),Math.min(a,b)));
}
public static Long lcm(Long max,Long min){
Long answer = max;
for(Long i = 1l;i<=min;i++){
answer = max*i;
if(answer%min==0){
return answer;
}
}
return answer;
}
} import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt(), b = in.nextInt();
System.out.println(a*b/gcd(a,b));
}
// 辗转相除法求最大公因数
public static int gcd(int a, int b) {
if (a % b == 0) return b;
return gcd(b, a % b);
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int num1 = scanner.nextInt();
int num2 = scanner.nextInt();
int result = 1;
// i <= Math.min(num1, num2)防止两数成倍数关系
for (int i = 2; i <= Math.min(num1, num2); i++) {
if (num1 % i == 0 && num2 % i == 0) {
// 先把公约数进行乘积运算
result *= i;
num1 /= i;
num2 /= i;
i--;
}
}
//将所有公约数乘积后再对没有除尽的进行乘积运算
result *= num1 * num2;
System.out.println(result);
}
scanner.close();
}
} import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
int n = sc.nextInt();
int bottom = Math.max(m, n);
while (true) {
if (bottom % m == 0 && bottom % n == 0) {
break;
}
bottom++;
}
System.out.println(bottom);
}
} import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
int num1 = in.nextInt();
int num2 = in.nextInt();
for(int i = num1 > num2 ? num1 : num2; i <= num1 * num2; i++){
if(i % num1 == 0 && i % num2 == 0){
System.out.println(i);
break;
}
}
}
}
} import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int a = scanner.nextInt();
int b = scanner.nextInt();
int result = 1;
// 所有公约数相乘
for (int i = 2;i<=Math.min(a,b);i++) {
while (a%i==0 && b%i==0){
result*=i;
a = a/i;
b = b/i;
}
}
result = result*a*b;
System.out.println(result);
}
}
} import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int A = in.nextInt();
int B = in.nextInt();
for (int i = Math.min(A,B); i <= A*B; i++){
if ((i%A==0) && (i%B==0)){
System.out.println(i);
break;
}
}
}
} import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt(), b = in.nextInt();
System.out.println((a * b) / gcd(a, b));
}
public static int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
} import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
// 最小公倍数 = a*b/(ab的最大公约数)
if (a < b) {
int temp = a;
a = b;
b = temp;
}
System.out.println(a * b / zdgys(a, b));
}
public static int zdgys(int a, int b) {
int c = a % b;
if (c == 0) return b;
return zdgys(b, c);
}
}