Two number least common multiple

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.