题解 | #求最小公倍数#
求最小公倍数
http://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3
#include #include #include using namespace std; int func(int n1,int n2) { for(int i=n1;i<=n1n2;++i) { if(i%n1==0&&i%n2==0) return i; } return n1n2; } int main() { int n1,n2; while(cin>>n1>>n2) { cout<<func(n1,n2)<<endl; } return 0; }