Basic Algorithms of C language: 10-maximum common divisor and least common multiple; minimum common multiple

Source: Internet
Author: User

Basic Algorithms of C language: 10-maximum common divisor and least common multiple; minimum common multiple
/*
========================================================== ======================================
Question: calculate the maximum or least common number of two numbers.
========================================================== ======================================
*/
# Include <stdio. h>
Main ()
{
Int m, n, r, t, j, q;
Printf ("input two integers: \ n ");
Scanf ("% d", & m, & n );
If (n> m)
{
T = m;
M = n;
N = t;
}
J = m * n;
While (r = m % n )! = 0)
{
M = n;
N = r;
}
Printf ("maximum common Appointment: % d \ n", n );
Printf ("minimum public multiple: % d \ n", j/n );
}
/*
========================================================== ======================================
Comment: enter two integers so that m> n. If the remainder is not 0, the dividend is equal to divisor and divisor.
After the remainder, until the remainder is 0, the divisor is the largest common divisor, and the least common multiple is the product of two numbers.
Divide by the maximum number of common appointments.
========================================================== ======================================
*/



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.