最小公倍数(Least Common Multiple):
求 a, b 的最小公倍数,即求最小正整数, 使得
,
,
a, b两数的最小公倍数为两数的乘积除以他们的最大公约数
T
最小公倍数
描述: 给定两个正整数,计算这两个数的最小公倍数。
输入: 输入包含多组测试数据,每组只有一行,包括两个不大于 1000 的正整数。
输出: 对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。
样例输入:
10 14
样例输出:
70
//
// main.cpp
// LCM
//
// Created by Apple on 2019/8/19.
// Copyright © 2019 Apple_Lance. All rights reserved.
//
#include <iostream>
#include <stdio.h>
int gcd(int a, int b){
return b != 0 ? gcd(b, a % b) : a;
}
int main(int argc, const char * argv[]) {
// insert code here...
int a, b;
while(scanf("%d%d", &a, &b) != EOF)
printf("%d", a * b/gcd(a, b));
return 0;
}