C Algorithm for Finding the maximum common divisor and the minimum common multiple

Source: Internet
Author: User

C Algorithm for Finding the maximum common divisor and the minimum common multiple


The algorithm process is as follows: premise: set two numbers to a, B to set a to divisor, B to divisor, and temp to remainder.

1. place large numbers in a and decimal places in B;

2. Calculate the remainder of a/B;

3. If temp = 0, B is the maximum common divisor;

4. If temp! = 0, the value of B is given to the value of a and temp to B;

5. Return step 2;

# Include

 
  
# Include

  
   
Void main () {int divisor (int a, int B); int multiple (int a, int B); printf ("The highest common divisor is % d \ n ", divisor (15,9); printf ("The lowest common multiple is % d \ n", multiple (15,9);} int divisor (int a, int B) {int temp; if (

   

    


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.