Theory: Number Theory (1): Divisible, gcd, and LCM

Source: Internet
Author: User
Tags greatest common divisor

The nature of divisible Division

Set A, B is two integers, and b≠0. If there is an integer c, so that a = b * C, it is said that A is divisible by B, or B is divisible by a, as b |a(here is a is divisible by B, a >= b)
At this time also called A is a multiple of B, B is a factor. If B does not divide a, remember

• Divide the basic definition

Definition 1.1: If n is 2 in addition to the remainder of 0, then for an integer k, there is n = 2k, we call n is an even number, and if the remainder of n by 2 is 1, we have n = 2k + 1 for an integer k, we call n an odd number.
definition 1.2: Set A, B is two integers, and b≠0, there is a unique integer q and R, which makes:
.


This expression is called the band-rest division and is recorded as R = A (mod b); for example -13 mod 5 = 3

• The nature of divisible

.


.
.
.
.

Application of divisible

the number of digits divisible
Fibonacci divisible

···· GCD and LCM Basic definitions

Definition 1.3: Set A and B are two integers, if d|a, and d|b, then we call D a common factor of A and B.
definition 1.4: Set A and B are two integers that are not all 0, the largest of the common factors of A and B is the largest common factor of a and B, or greatest common divisor, which is recorded as GCD (A, b), sometimes précis-writers (A, B)
Definition 1.5: Set A and B are two non-0 certificates, the minimum positive common multiple of a and B are least common multiple of A and B, recorded as LCM (A, b), sometimes précis-writers to [A, b]

Basic Operation Properties

.


.
.
.
.

About the operations of GCD and LCM

.


.
The above two figures are the legendary Euclidean theorem.

Proof of the nature of GCD operation

Brief proof:

We say that the recursion is true because any common factor of M and N must also be the male factor of M and (n mod m).
Proof that the above sentence is based on the following formula
.

Here we can introduce the Euclidean theorem of expansion.

Full proof:

where (A,b,q,r) ∈z is set, then:
.


! Certificate: Only A and B, B and r have the same common factor.
(1). Set D is the common factor of A and B, i.e. (D|a) and (d|b). We notice that
.
So that we can get the following derivation process:
.
Here we prove the positive determination in the case of a|b (that is, gcd (0,n) is correct in the expression above)
·
(2). Set D is the common factor of B and r, so we have the following derivation:
.

Pseudo-code description of GCD and LCM algorithms
while(max0)    min→temp    maxmodmin→min    temp→maxreturn <max>
Examples

Two-Instrument Sword

Theory: Number Theory (1): Divisible, gcd, and LCM

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.