# Wilson’s theorem and related problems in Elementary Number Theory for RMO

I) Prove Wilson’s Theorem:

If p is a prime, then $(p-1)! \equiv -1 {\pmod p}$.

Proof:

The cases for primes 2 and 3 are clearly true.

Assume $p>3$

Suppose that a is any one of the p-1 positive integers $1,2,3, \ldots {p-1}$ and consider the linear congruence
$ax \equiv 1 {\pmod p}$. Then, $gcd(a,p)=1$.

Now, apply the following theorem: the linear congruence $ax \equiv b {\pmod n}$ has a solution if and only if $d|b$, where $d = gcd(a,b)$. If $d|b$, then it has d mutually incongruent solutions modulo n.

So, by the above theorem, the congruence here admits a unique solution modulo p; hence, there is a unique integer $a^{'}$, with $1 \leq a^{'} \leq p-1$, satisfying $aa^{'} \equiv 1 {\pmod p}$.

Because p is prime, $a = a^{'}$ if and only if $a=1$ or $a=p-1$. Indeed, the congruence $a^{2} \equiv 1 {\pmod p}$ is equivalent to $(a-1)(a+1) \equiv 0 {\pmod p}$. Therefore, either $a-1 \equiv 0 {\pmod p}$, in which case $a=1$, or $a+1 \equiv 0 {\pmod p}$, in which case $a=p-1$.

If we omit the numbers 1 and p-1, the effect is to group the remaining integers $2,3, \ldots (p-2)$ into pairs $a$ and $a^{'}$, where $a \neq a^{'}$, such that the product $aa^{'} \equiv 1 {\pmod p}$. When these $(p-3)/2$ congruences are multiplied together and the factors rearranged, we get

$2.3. \ldots (p-2) \equiv 1 {\pmod p}$

or rather

$(p-2)! \equiv 1 {\pmod p}$

Now multiply by p-1 to obtain the congruence

$(p-1)! \equiv p-1 \equiv -1 {\pmod p}$, which was desired to be proved.

An example to clarify the proof of Wilson’s theorem:

Specifically, let us take prime $p=13$. It is possible to divide the integers $2,3,4, \ldots, 11$ into $(p-3)/2=5$ pairs, each product of which is congruent to 1 modulo 13. Let us write out these congruences explicitly as shown below:

$2.7 \equiv 1 {\pmod {13}}$
$3.9 \equiv 1 {\pmod {13}}$
$4.10 \equiv 1 {\pmod {13}}$
$5.8 \equiv 1 {\pmod {13}}$
$6.11 \equiv 1 {\pmod {13}}$

Multpilying these congruences gives the result $11! = (2.7)(3.9)(4.10)(5.8)(6.11) \equiv 1 {\pmod {13}}$

and as $12! \equiv 12 \equiv -1 {\pmod {13}}$

Thus, $(p-1)! \equiv -1 {\pmod p}$ with prime $p=13$.

Further:

The converse to Wilson’s theorem is also true. If $(n-1)! \equiv -1 {\pmod n}$, then n must be prime. For, if n is not a prime, then n has a divisor d with $1 1$ is prime if and only if $(n-1)! \equiv -1 {\pmod n}$. Unfortunately, this test is of more theoretical than practical interest because as n increases, $(n-1)!$ rapidly becomes unmanageable in size.

Let us illustrate an application of Wilson’s theorem to the study of quadratic congruences{ What we mean by quadratic congruence is a congruence of the form $ax^{2}+bx+c \equiv 0 {\pmod n}$, with $a \not\equiv 0 {\pmod n}$ }

Theorem: The quadratic congruence $x^{2}+1 \equiv 0 {\pmod p}$, where p is an odd prime, has a solution if and only if $p \equiv 1 {\mod 4}$.

Proof:

Let a be any solution of $x^{2}+1 \equiv 0 {\pmod p}$ so that $a^{2} \equiv -1 {\pmod p}$. Because $p \not |a$, the outcome of applying Fermat’s Little Theorem is

$1 \equiv a^{p-1} \equiv (a^{2})^{(p-1)/2} \equiv (-1)^{(p-1)/2} {\pmod p}$

The possibility that $p=4k+3$ for some k does not arise. If it did, we would have

$(-1)^{(p-1)/2} = (-1)^{2k+1} = -1$

Hence, $1 \equiv -1 {\pmod p}$. The net result of this is that $p|2$, which is clearly false. Therefore, p must be of the form $4k+1$.

Now, for the opposite direction. In the product

$(p-1)! = 1.2 \ldots \frac{p-1}{2} \frac{p+1}{2} \ldots (p-2)(p-1)$

we have the congruences

$p-1 \equiv -1 {\pmod p}$
$p-2 \equiv -2 {\pmod p}$
$p-3 \equiv -3 {\pmod p}$
$\vdots$
$\frac{p+1}{2} \equiv - \frac{p-1}{2} {\pmod p}$

Rearranging the factors produces
$(p-1)! \equiv 1.(-1).2.(-2) \ldots \frac{p-1}{2}. (-\frac{p-1}{2}) {\pmod p} \equiv (-1)^{(p-1)/2}(.2. \ldots \frac{p-1}{2})^{2}{\pmod p}$

because there are $(p-1)/2$ minus signs involved. It is at this point that Wilson’s theorem can be brought to bear; for, $(p-1)! \equiv -1 {\pmod p}$, hence,

$-1 \equiv (-1)^{(p-1)/2}((\frac{p-1}{2})!)^{2} {\pmod p}$

If we assume that p is of the form $4k+1$, then $(-1)^{(p-1)/2} =1$, leaving us with the congruence

$-1 \equiv (-\frac{p-1}{2})^{2}{\pmod p}$.

The conclusion is that the integer $(\frac{p-1}{2})!$ satisfies the quadratic congruence $x^{2}+1 \equiv 0 {\pmod p}$.

Let us take a look at an actual example, say, the case $p=13$, which is a prime of the form $4k+1$. Here, we have $\frac{p-1}{2}=6$, and it is easy to see that $6! = 720 \equiv 5 {\pmod {13}}$ and $5^{2}+1 = 26 \equiv 0 {\pmod {13}}$.

Thus, the assertion that $((p-1)!)^{2}+1 \equiv 0 {\pmod p}$ is correct for $p=13$.

Wilson’s theorem implies that there exists an infinitude of composite numbers of the form $n!+1$. On the other hand, it is an open question whether $n!+1$ is prime for infinitely many values of n. Refer, for example:

https://math.stackexchange.com/questions/949520/are-there-infinitely-many-primes-of-the-form-n1

More later! Happy churnings of number theory!
Regards,
Nalin Pithwa

# A good way to start mathematical studies …

I would strongly suggest to read the book “Men of Mathematics” by E. T. Bell.

It helps if you start at a young age. It doesn’t matter if you start later because time is relative!! ðŸ™‚

Well, I would recommend you start tinkering with mathematics by playing with nuggets of number theory, and later delving into number theory. An accessible way for anyone is “A Friendly Introduction to Number Theory” by Joseph H. Silverman. It includes some programming exercises also, which is sheer fun.

One of the other ways I motivate myself is to find out biographical or autobiographical sketches of mathematicians, including number theorists, of course. In this, the internet is an extremely useful information tool for anyone willing to learn…

Below is a list of some famous number theorists, and then there is a list of perhaps, not so famous number theorists — go ahead, use the internet and find out more about number theory, history of number theory, the tools and techniques of number theory, the personalities of number theorists, etc. Become a self-learner, self-propeller…if you develop a sharp focus, you can perhaps even learn from MIT OpenCourseWare, Department of Mathematics.

Famous Number Theorists (just my opinion);

1) Pythagoras
2) Euclid
3) Diophantus
4) Eratosthenes
5) P. L. Tchebycheff (also written as Chebychev or Chebyshev).
6) Leonhard Euler
7) Christian Goldbach
8) Lejeune Dirichlet
9) Pierre de Fermat
10) Carl Friedrich Gauss
11) R. D. Carmichael
12) Edward Waring
13) John Wilson
14) Joseph Louis Lagrange
15) Legendre
16) J. J. Sylvester
11) Leonoardo of Pisa aka Fibonacci.
15) Srinivasa Ramanujan
16) Godfrey H. Hardy
17) Leonard E. Dickson
18) Paul Erdos
19) Sir Andrew Wiles
20) George Polya
21) Sophie Germain
24) Niels Henrik Abel
25) Richard Dedekind
26) David Hilbert
27) Carl Jacobi
28) Leopold Kronecker
29) Marin Mersenne
30) Hermann Minkowski
31) Bernhard Riemann

Perhaps, not-so-famous number theorists (just my opinion):
1) Joseph Bertrand
2) Regiomontanus
3) K. Bogart
4) Richard Brualdi
5) V. Chvatal
6) J. Conway
7) R. P. Dilworth
8) Martin Gardner
9) R. Graham
10) M. Hall
12) F. Harary
13) P. Hilton
14) A. J. Hoffman
15) V. Klee
16) D. Kleiman
17) Donald Knuth
18) E. Lawler
19) A. Ralston
20) F. Roberts
21) Gian Carlo-Rota
22) Bruce Berndt
23) Richard Stanley
24) Alan Tucker
25) Enrico Bombieri

Happy discoveries lie on this journey…
-Nalin Pithwa.

# Any integer can be written as the sum of the cubes of 5 integers, not necessarily distinct

Question: Prove that any integer can be written as the sum of the cubes of five integers, not necessarily.

Solution:

We use the identity $6k = (k+1)^{3} + (k-1)^{3}- k^{3} - k^{3}$ for $k=\frac{n^{3}-n}{6}=\frac{n(n-1)(n+1)}{6}$, which is an integer for all n. We obtain

$n^{3}-n = (\frac{n^{3}-n}{6}+1)^{3} + (\frac{n^{3}-n}{6}-1)^{3} - (\frac{n^{3}-n}{6})^{3} - (\frac{n^{3}-n}{6})$.

Hence, n is equal to the sum

$(-n)^{3} + (\frac{n^{3}-n}{6})^{3} + (\frac{n^{3}-n}{6})^{3} + (\frac{n-n^{3}}{6}-1)^{3}+ (\frac{n-n^{3}}{6}+1)^{3}$.

More later,
Nalin Pithwa.

# Some number theory training questions: RMO and INMO

Question 1:

Let us write an arbitrary natural number (for example, 2583), and then add the squares of its digits. ($2^{2}+5^{2}+8^{2}+3^{2}=102$). Next, we do the same thing to the number obtained. Namely, $1^{2}+0^{2}+2^{2}=5$. Now proceed further in the same way:

$5^{2}=25$, $2^{2}+5^{2}=29$, $2^{2}+9^{2}=85, \ldots$.

Prove that unless this procedure leads to number 1 (in which case, the number 1 will, of course, recur indefinitely), it must lead to the number 145, and the following cycle will repeat again and again:

145, 42, 20, 4, 16, 37, 58, 89.

Question 2:

Prove that the number $5^{5k+1} + 4^{5k+2} + 3^{5k}$ is divisible by 11 for every natural k.

Question 3:

The number $3^{105} + 4^{105}$ is divisible by 13, 49, 181 and 379, and is not divisible by either 5 or by 11. How can this result be confirmed?

Cheers,

Nalin Pithwa.

# Solution to a “nice analysis question for RMO practice”

The question from a previous blog is re-written here for your convenience.Â

Question:

How farthest from the edge of a table can a deck of playing cards be stably overhung if the cards are stacked on top of one another? And, how many of them will be overhanging completely away from the edge of the table?

Solution:

The figure below shows how two and three cards can be stacked so that the mass of cards is equal on either side of the vertical line passing through the corner of table’s edge in order to just balance them under gravity:

the set of first two cards are arranged as follows (the horizontal lines represents the cards):

$xxxxxxxxxxxxxxxx\line(5,0){170}$

$\line(5,0){150}xxxxxxxxxxxxxxxxxxx$

the set of three cards are arranged as follows:

$xxxxxxxxxxxxxxxxxxxxxx\line(5,0){150}$

$xxxxxxxxxxxxx\line(5,0){150}$

$\line(5,0){150}xxxxxxxxxxxxxxxxxxxxxx$

We can see that the length of the overhand is a harmonic series of even numbers multiplied by the length of one card, L.

Overhand distance is $(\frac{1}{2} + \frac{1}{4} + \frac{1}{6} + \ldots + \frac{1}{52 \times 2})L$ for 52 cards.

It may be noted that the series if continued to infinity leads to $H_{\infty}^{E}$.

That is, $H_{\infty}^{E}=\frac{1}{2} + \frac{1}{4} + \frac{1}{6} + \frac{1}{8} + \ldots$

This series is known to diverge as proved below:

First consider, $H_{\infty}=1+ \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \frac{1}{5} + \frac{1}{6} + \frac{1}{7} + \frac{1}{8}+ \ldots$, which is, greater than

$1+ \frac{1}{2} + \frac{1}{4} + \frac{1}{4} + \frac{1}{8} + \frac{1}{8} + \frac{1}{8} + \frac{1}{8}+ \ldots$, which is greater than $1+ \frac{1}{2} + \frac{1}{2} + \frac{1}{2} + \ldots$. Hence, $H_{\infty}$ diverges as we go on adding 1/2 indefinitely.

Now, let $H_{E}=\frac{1}{2} + \frac{1}{4} + \frac{1}{6} + \frac{1}{8} + \ldots = \frac{1}{2}(1+ \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \ldots)=\frac{1}{2}H_{\infty}$

Since $H_{\infty}$ diverges, $H_{E}$also diverges.

Hence, the “overhang series” also diverges.

This means that the cards can be stacked indefinitely and the overhang distance can reach infinity. However, this will happen very slowly as shown in the table below:

$\begin{array}{cc} n^{E} & H_{n}^{E}\\ 2 & 0.5 \\ 10 & 1.46 \\ 100 & 2.59 \\ 1000 & 3.74 \\ 10000 & 4.89 \\ 100000 & 6.05 \end{array}$

Computing the number of cards that completely overhang off the table needs information about the overhang distance for different number of cards. As shown below in the figure, four cards are required to have one card completely away from the edge of the table. This is because $(\frac{1}{2} + \frac{1}{4} + \frac{1}{6} + \frac{1}{8}=1.0417 >1)$.

(the set of four cards are arranged as follows:)

$xxxxxxxxxxxxxxxxxxxxxxxxxxxx\line(5,0){150}$

$xxxxxxxxxxxxxxxx\line(5,0){150}$

$xxxxxxxxxx\line(5,0){150}$

$xxxxx\line(5,0){150}$

We can see that the length of the overhang is a harmonic series of even numbers multiplied by the length of one card, L:

Overhang distance = $(\frac{1}{2} + \frac{1}{4} + \frac{1}{6} + \ldots + \frac{1}{52 \times 2})L$ for 52 cards

It may be noted that the series if continued to infinity, leads to $H_{\infty}^{E}$

$H_{\infty}^{E} = \frac{1}{2} + \frac{1}{4} + \frac{1}{6} + \frac{1}{8} + \ldots$

This series is known to diverge. This means that the cards can be stacked indefinitely and the overhang can reach infinity. However, this will happen very slowly as shown in the table below:

$\begin{array}{cc} n^{E} & H_{\infty}^{E} \\ 2 & 0.5 \\ 10 & 1.46 \\ 100 & 2.59 \\ 1000 & 3.74 \\ 10000 & 4.89 \\ 100000 & 6.05 \end{array}$

Computing the number of cards that completely overhang off the table needs information about the overhang distance for different numbers of cards. As shown in the above schematic figures of cards with overhangs, four cards are required to have one card completely away from the edge of the table. This is because

$(\frac{1}{2} + \frac{1}{4} + \frac{1}{6} + \frac{1}{8})=1.0417>1$

For the second card to overhang completely, leaving the first card (and hence one half) that is already completely overhung, it is now necessary that

$(\frac{1}{4} + \frac{1}{6} + \frac{1}{8} + \ldots + \frac{1}{2n})>1$, or

$(\frac{1}{2} + \frac{1}{4} + \frac{1}{6} + \frac{1}{8} + \ldots + \frac{1}{2n} )>1+ \frac{1}{2}$

where n needs to be found out. By generating some more data, we can find the value of n to be 11.

For third overhanging card, we need

$(\frac{1}{6} + \frac{1}{8} + \ldots + \frac{1}{2n})>1$ or

$(\frac{1}{2} + \frac{1}{4} + \frac{1}{6}+\frac{1}{8}+ \ldots + \frac{1}{2n})>1+\frac{1}{2} + \frac{1}{4}$

Thus, for m completely overhanging cards, we find n such that $H_{2n}^{E} > 1+ H_{2(m-1)}^{E}$

The table below shows these values wherein we see an approximate pattern of arithmetic progression by 7.

$\begin{array}{cccc} m & n & m & n \\ 1 & 4 & 11 & 78 \\ 2 & 11 & 12 & 85 \\ 3 & 19 & 13 & 92 \\ 4 & 26 & 14 & 100 \\ 5 & 33 & 15 & 107 \\ 6 & 41 & 16 & 115 \\ 7 & 48 & 17 & 122 \\ 8 & 55 & 18 & 129 \\ 9 & 63 & 19 & 137 \\ 10 & 70 & 20 & 144 \end{array}$

By examining the pattern in the table, we can get a simple rule to estimate the number of completely overhanging number of cards m, with an error of utmost one, for n cards stacked.

$m = round(\frac{n}{7.4})=round(\frac{10n}{74})$.

Reference:

Popular Problems and Puzzles in Mathematics by Asok Kumar Mallik, IISc Press,Â Foundation Books.

Hope you enjoyed the detailed analysis…

More later,

Nalin Pithwa

# Pick’s theorem: a geometry problem for RMO practice

Pick’s theorem:

Consider a square lattice of unit side. A simple polygon (with non-intersecting sides) of any shape is drawn with its vertices at the lattice points. The area of the polygon can be simply obtained as $B/2+I-1$ square units, where B is the number of lattice points on the boundary; I = number of lattice points in the interior region of the polygon. Prove this theorem.

Proof:

Refer Wikipedia ðŸ™‚ ðŸ™‚ ðŸ™‚

https://en.wikipedia.org/wiki/Pick%27s_theorem

Cheers,

Nalin Pithwa.