We switch back to basic number theory for the express purpose of Pre-RMO, RMO and IITJEE Foundation Mathematics.

As we have already seen in a previous blog on Pythagorean triples, the notions of divisibility and factorizations are important tools in number theory. In this blog, we will look at these ideas more closely.

Suppose that m and n are integers with . We say that m divides n, if n is a multiple of m, that is, if there is an integer k so that . If m divides n, we write m|n. Similarly, if m does not divide n, then we write

. For example, 3|6 and 12|132 since 6=3.2 and 132=12.11

The divisors of 6 are 1,2,3 and 6. On the other hand, since no integer multiple of 5 is equal to 7. A number that divides n is called a divisor of n.

If we are given two numbers, we can look for common divisors, that is, numbers that divide both of them. For example, 4 is a common divisor of 12 and 20, since 4|12 and 4|20. Notice that 4 is the largest common divisor of 12 and 20. Similarly, 3 is a common divisor of 18 and 30, but it is not the largest, since 6 is also a common divisor. The largest common divisor of two numbers is an extremely important quantity that will frequently appear during our number theoretic excursions.

The * greatest common divisor *of two numbers a and b (not both zero) is the largest number that divides both of them. It is denoted by . If

, we say that a and b are **relatively prime or co-prime.**

Two examples that we mentioned above are

and .

Another example is

We can check that this answer is correct by factoring and

but, in general, factoring a and b is not an efficient way to compute their GCD or HCF.

The most efficient method known for finding the GCD of two numbers is called the Euclidean algorithm. It consists of doing a sequence of divisions with remainder until the remainder is zero. We will illustrate with an example before describing the general method.

As our example, we will compute the The first step is to divide 132 by 36, which gives a quotient of 3 and a remainder of 24. We write this as

The next step is to 36 and divide it by the remainder 24 from the previous step. This gives

Next divide 24 by 12, and we find a remainder of 0,

The Euclidean algorithm says that when you get a remainder of 0 then the remainder from the previous step is the GCD of the original two numbers. So, in this case we find that the .

Notice how at each step we replace our old A and B with the numbers B and R and continue the process until we get a remainder of 0. At that point, the remainder R from the previous step is the GCD of our original two numbers.

There is one more practical matter to be mentioned before we undertake a theoretical analysis of the Euclidean algorithm. If we are given A and B, how can we find a quotient Q and the remainder R? Of course, you can always use long division, but that can be time consuming and subject to arithmetic errors if A and B are large. A pleasant alternative is to find a calculator or computer program that will automatically compute Q and R for you. However, even if you are only equipped with an inexpensive calculator, there is an easy three-step method to find Q and R:

**Method to compute Q and R on a Calculator so that **

1) Use the calculator to divide A by B. You get a number with decimals.

2) Discard all the digits to the right of the decimal point. This gives Q.

3) To find R, use the formula .

For example, suppose that and . Then,

so and

**We are now ready to analyze the Euclidean algorithm. The general method looks like:**

**If we let and , then every line looks like :**

.

**Why is the last non zero remainder a** **common divisor of a and b?**

*We start from the bottom and work our way up. *The last line $r_{n-1}=r_{n]$. Now, looking at the line above that, we already know that $r_{n}$ divides both $r_{n-1}$ and $r_{n-2}$ so we find that $r_{n}$ also divides $r_{n-3}$. Moving up line by line… finally, we move up to the top line and use fact that $r_{n}$ divides both $r_{1}$ and b to conclude that $r_{n}$ also divides a. This completes our verification that the last nonzero remainder $r_{n}$ is a common divisor of a and b.

**But, why is the greatest common divisor of a and b? **

Suppose that d is any common divisor of a and b. We will work our way back down the list of equations. So, from the first equation and the fact that d divides both a and b, we see that d also divides . Then, the second equation shows us that d must divide . Counting down line by line…therefore, must be the greatest common divisor of a and b.

This completes our verification that the Euclidean algorithm actually computes the greatest common divisor, a fact of sufficient importance to be officially recorded.

**Theorem (Euclidean Algorithm) **To compute the greatest common divisor of two numbers a and b, let , let $;atex r_{0}=b$, and compute successive quotients and reminders

for and some remainder is 0. The last nonzero remainder is then the greatest common divisor of a and b.

**Fun with computer programming: you can write a computer program to compute the gcd of large numbers ! Try its very easy and real fun 🙂**