Talk C Chestnut Bar (Nineth: C-language example-greatest common divisor)

Source: Internet
Author: User
Tags greatest common divisor


Hello, crossing. Starting today, we talk about the big couplet sci-tech fiction: C chestnuts, which is the C language example. Gossip Hugh,

Words return to the positive turn. Let's talk C chestnuts together!



Crossing, they are. What we said last time is a sample of prime numbers. This time we say the example is: greatest common divisor.


Crossing, greatest common divisor also called the largest common factor. The number of conventions in two integers is several. The largest of these conventions is called the most

Number of major conventions. Of course, this is a concept in mathematics, the hypothesis is not clear, to be able to consult the relevant mathematical knowledge.


There are several ways to find greatest common divisor. The most commonly used is the Euclidean algorithm, also known as Euclid. The principle of the algorithm is as follows:

1. Assume that the remainder of a positive integer a divided by a positive integer B is c. Then the greatest common divisor of a and B are equal to the maximum number of Conventions B and C.

2. Repeat the operation in step 1 to continue with the greatest common divisor of B and C. Repeat until the remainder equals 0.


Crossing, the text does not write code, the specific code put in my resources, you can click the link to download the use.


You crossing. Here's a sample of greatest common divisor.

I want to know what the following example, and listen to tell.

Talk C Chestnut Bar (Nineth: C-language example-greatest common divisor)

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.