# Some Basics for RMO Number Theory: Congruences

I. The congruence notation:

It often happens that for the purposes of a particular calculation, two numbers which differ by a multiple of some fixed number are equivalent, in the sense that they produce the same result. For example, the value of $(-1)^{n}$ depends only on whether n is odd or even, so that two values of n which differ by a multiple of 2 give the same result. Or again, if we are concerned only with the last digit of a number, then for that purpose two numbers which differ by a multiple of 10 are effectively the same.

The congruence notation, introduced by Gauss, serves to express in a convenient form the fact that the two integers a and b differ by a multiple of a fixed natural number m. We say that a is congruent to b with respect to the modulus m, or in symbols,

$a \equiv b {\pmod m}$

The meaning of this, then, is simply that $a-b$ is divisible by m. The notation facilitates calculations in which numbers differing by a multiple of m are effectively the same, by stressing the analogy between congruence and equality. Congruence, in fact, means “equality except for the addition of some multiple of m”.

A few examples of valid congruences are :

$63 \equiv 0 {\pmod 3}$; $7 \equiv -1 {\pmod 8}$; $5^{2} \equiv -1 {\pmod {13}}$

A congruence to the modulus 1 is always valid, whatever the two numbers may be, since every number is a multiple of 1. Two numbers are congruent with respect to the modulus 2 if they are of the same parity, that is, both even or both odd.

Two congruences can be added, subtracted or multiplied together, in just the same way as two equations, provided all the congruences have the same modulus. If

$a \equiv \alpha {\pmod m}$ and $b \equiv \beta {\pmod m}$

then:

$a + b \equiv {\alpha + \beta} {\pmod m}$

$a - b \equiv {\alpha - \beta}{\pmod m}$

$ab \equiv {\alpha\beta} {\pmod m}$

The first two of these statements are immediate: for example, $(a+b) - (\alpha + \beta)$ is a multiple of m because $a- \alpha$ and $b - \beta$ are both multiples of m. The third is not quite so immediate because $ab - \alpha \beta = (a-\alpha)b$, and $a - \alpha$ is a multiple of m. Next, $ab \equiv \alpha \beta$, for a similar reason. Hence, $ab \equiv {\alpha \beta} {\pmod m}$.

A congruence can always be multiplied throughout by any integer; if $a \equiv {\alpha} {\pmod m}$ the10n $ka \equiv {k\alpha} {\pmod m}$. Indeed this is a special case of the third result above, where $b$ and $\beta$ are both k. But, it is not always legitimate to cancel a factor from a congruence. For example, $42 \equiv 12 {\pmod 10}$, but it is not permissible to cancel the factor 6 from the numbers 42 and 12, since this would give the false result $7 \equiv 2 {\pmod 10}$. The reason is obvious: the first congruence states that $42-12$ is a multiple of 10, but this does not imply that $\frac{1}{6}(42-12)$ is a multiple of 10. The cancellation of a factor from a congruence is legitimate if the factor is relatively prime to the modulus. For, let the given congruence be $ax \equiv ay {\pmod m}$, where is the factor to be cancelled, and we suppose that a is relatively prime to m. The congruence states that $a(x-y)$ is divisible by m, and hence, $(x-y)$ is divisible by m.

An illustration of the use of congruences is provided by the well-known rules for the divisibility of a number by 3 or 9 or 11. The usual representation of a number n by digits in the scale of 10 is really a representation of n in the form

$n = a + 10b + 100c + \ldots$

where a, b, c, … are the digits of the number, read from right to left, so that a is the number of units, b the number of tens, and so on. Since $10 \equiv 1 {\pmod 9}$, we have also $10^{2} \equiv 1 {\pmod 9}$, and $10^3 \equiv 1 {\pmod 9}$, and so on. Hence, it follows from the above representation of n that

$n \equiv {a+b+c+\ldots} {\pmod 9}$

In other words, any number n differs from the sum of its digits by a multiple of 9, and in particular n is divisible by 9 if and only if the sum of its digits is divisible by 9. The same applies with 3 in place of 9 throughout.

The rule for 11 is based on the fact that $10 \equiv -1 {\pmod 11}$ so that $10^2 \equiv {+1} {\pmod 11}$, and so on. Hence,

$n \equiv {a-b+c- \ldots} {\pmod 11}$

It follows that n is divisible by 11 if and only if $a-b+c-\ldots$ is divisible by 11. For example, to test the divisibility of 958 by 11 we form 1-8+5-9, or -11. Since this is divisible by 11, so is 9581.

Ref: The Higher Arithmetic by H. Davenport, Eighth Edition, Cambridge University Press.

Cheers,

Nalin Pithwa.

# Is there a Fermat in you?? A solution possible

Reference: Popular Problems and Puzzles in Mathematics, Asok Kumar Mallik, Foundation Books, IISc Press.

https://www.amazon.in/Popular-Problems-Puzzles-Mathematics-Mallik/dp/938299386X/ref=sr_1_1?s=books&ie=UTF8&qid=1519414577&sr=1-1&keywords=Popular+problems+and+puzzles+in+mathematics

Fermat’s Problem:

Pierre de Fermat (1601-65), the great French mathematical genius, is described as the “Prince of Amateurs”, as he was not a professional mathematician and never published any work during his lifetime. As a civil servant, he served in the judiciary and spent his leisure with mathematics as his hobby. He corresponded with the best of mathematicians of his time. He teased the contemporary English mathematicians, Wallis and Digby, with the following problem, who had to admit defeat:

26 is a number that is sandwiched between a perfect square (25) and a perfect cube (27). Prove that there is no such number.

Solution:

We show that the equation $y^{3}=x^{2}+2$ has only one solution for positive integers x and y, viz., $x=5$ and $y=3$. First, we write $y^{3}=x^{2}+2=(x+i\sqrt{2})(x-i\sqrt{2})$. It can be shown that unique prime factorization occurs in the complex number system $a+ ib\sqrt{2}$. It can be also argued that since the product of the two complex numbers of that form is a cube, each factor must be a cube. So, we write:

$x+i\sqrt{2}=(a+ib\sqrt{2})^{3}=a^{3}-6ab^{2}+i(3a^{2}b-2b^{3})\sqrt{2}$.

Equating imaginary parts of both sides, we get

$3a^{2}b-2b^{3}=b(3a^{2}-2b^{2})=1$.

Thus, $b=\pm 1$ and $3a^{2}-2b^{2}=\pm 1$, both having the same sign. But, with $b=-1$, one gets $a^{2}=1/3$, which is not possible. So, we take $b=1$ when $a=\pm 1$. Finally, with $a=1$, $x=-5$ and with $a=-1, x=5$. The sign of x is irrelevant as only $x^{2}$ is involved in the original equation. With the solution $x=5$, we get $y=3$ as the only set of solution.

Cheers,

Nalin Pithwa.

# Is there a “Fermat” in you? ? :-)

Fermat’s problem:

Pierre de Fermat (1601-65), the great French mathematical genius, is described as the “Prince of Amateurs” as he was not a professional mathematician and never published any work during his lifetime. As a civil servant, he served in the judiciary and spent his leisure with mathematics as his hobby. He corresponded with the best of mathematicians of his time. He teased the contemporary English mathematicians, Wallis and Digby, with the following problem, who had to admit defeat.

Problem:

26 is a number that is sandwiched between a perfect square (25) and a perfect cube (27). Prove that there is no other such number.

Please do try and let me know your solutions. Even partial solutions are welcome.

Cheers,

Nalin Pithwa.

# Happy Numbers make Happy Programmers ! :-)

Here is one question which one of my students, Vedant Sahai asked me. It appeared in his computer subject exam of his recent ICSE X exam (Mumbai):

write a program to accept a number from the user, and check if the number is a happy number or not; and the program has to display a message accordingly:

A Happy Number is defined as follows: take a positive number and replace the number by the sum of the squares of its digits. Repeat the process until the number equals 1 (one). If the number ends with 1, then it is called a happy number.

For example: 31

Solution : 31 replaced by $3^{2}+1^{2}=10$ and 10 replaced by $1^{2}+0^{2}=1$.

So, are you really happy? 🙂 🙂 🙂

Cheers,

Nalin Pithwa.

# Yet another special number !

The eminent British mathematician had once remarked: Every integer was a friend to Srinivasa Ramanujan.

Well, we are mere mortals, yet we can cultivate some “friendships with some numbers”. Let’s try:

Question:

Squaring 12 gives 144. By reversing the digits of 144, we notice that 441 is also a perfect square. Using C, C++, or python, write a program to find all those integers m, such that $1 \leq m \leq N$, verifying this property.

PS: in order to write some simpler version of the algorithm, start playing with small, particular values of N.

Reference: 1001 Problems in Classical Number Theory, Indian Edition, AMS (American Mathematical Society), Jean-Marie De Konick and Armel Mercier.