Enter the code:
/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Sum123.cpp * Creator: Lin Haiyun * Completion date: January 10, 2015 * version number: v2.0 * * Problem Description: Two number of least common multiple * input description: Two integer * program output: Least common Multiple */ #include <iostream>using namespace std;int gcd (int x,int y); int gad (int x,int y); int main () { int m , N,sum; cin>>m>>n; Sum=gad (m,n); cout<<sum<<endl; return 0;} int gcd (int x,int y) { int r; while (y!=0) { r=x%y; x=y; y=r; } return x;} int gad (int x,int y) { int s,d; S=x*y; D=S/GCD (x, y); return D;}
Operation Result:
Summary: Two number of least common multiple = two number of the product/two number of the minimum number of conventions;
The minimum number of conventions is calculated by the method of M,n, the remainder of which is divided into two numbers is r,r=x%y,x=y,y=r;
Two number least common multiple