Questions based on Wilson’s theorem for training for RMO

1(a) Find the remainder when 15! is divided by 17.
1(b) Find the remainder when 2(26!) is divided by 29.

2: Determine whether 17 is a prime by deciding if 16! \equiv -1 {\pmod 17}

3: Arrange the integers 2,3,4, …, 21 in pairs a and b that satisfy ab \equiv 1 {\pmod 23}.

4: Show that 18! \equiv -1 {\pmod 437}.

5a: Prove that an integer n>1 is prime if and only if (n-2)! \equiv 1 {\pmod n}.
5b: If n is a composite integer, show that (n-1)! \equiv 0 {\pmod n}, except when n=4.

6: Given a prime number p, establish the congruence (p-1)! \equiv {p-1} {\pmod {1+2+3+\ldots + (p-1)}}

7: If p is prime, prove that for any integer a, p|a^{p}+(p-1)|a and p|(p-1)!a^{p}+a

8: Find two odd primes p \leq 13 for which the congruence (p-1)! \equiv -1 {\pmod p^{2}} holds.

9: Using Wilson’s theorem, prove that for any odd prime p:
1^{2}.3^{2}.5^{2}.\ldots (p-2)^{2} \equiv (-1)^{(p+1)/2} {\pmod p}

10a: For a prime p of the form 4k+3, prove that either

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

10b: Use the part (a) to show that if 4k+3 is prime, then the product of all the even integers less than p is congruent modulo p to either 1 or -1.

More later,
Nalin Pithwa.

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}.


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.


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}.


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}
\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:

More later! Happy churnings of number theory!
Nalin Pithwa

Eight digit bank identification number and other problems of elementary number theory

Question 1:

Consider the eight-digit bank identification number a_{1}a_{2}\ldots a_{8}, which is followed by a ninth check digit a_{9} chosen to satisfy the congruence

a_{9} \equiv 7a_{1} + 3a_{2} + 9a_{3} + 7a_{4} + 3a_{5} + 9a_{6} + 7a_{7} + 3a_{8} {\pmod {10}}

(a) Obtain the check digits that should be appended to the two numbers 55382006 and 81372439.

(b) The bank identification number 237a_{4}18538 has an illegitimate fourth digit. Determine the value of the obscured digit.

Question 2:

(a) Find an integer having the remainders 1,2,5,5 when divided by 2, 3, 6, 12 respectively (Yih-hing, died 717)

(b) Find an integer having the remainders 2,3,4,5 when divided by 3,4,5,6 respectively (Bhaskara, born 1114)

(c) Find an integer having remainders 3,11,15 when divided by 10, 13, 17, respectively (Regiomontanus, 1436-1476)

Question 3:

Question 3:

Let t_{n} denote the nth triangular number. For which values of n does t_{n} divide t_{1}^{2} + t_{2}^{2} + \ldots + t_{n}^{2}

Hint: Because t_{1}^{2}+t_{2}^{2}+ \ldots + t_{n}^{2} = t_{n}(3n^{3}+12n^{2}+13n+2)/30, it suffices to determine those n satisfying 3n^{3}+12n^{2}+13n+2 \equiv 0 {\pmod {2.3.5}}

Question 4:

Find the solutions of the system of congruences:

3x + 4y \equiv 5 {\pmod {13}}
2x + 5y \equiv 7 {\pmod {13}}

Question 5:

Obtain the two incongruent solutions modulo 210 of the system

2x \equiv 3 {\pmod 5}
4x \equiv 2 {\pmod 6}
3x \equiv 2 {\pmod 7}

Question 6:

Use Fermat’s Little Theorem to verify that 17 divides 11^{104}+1

Question 7:

(a) If gcd(a,35)=1, show that a^{12} \equiv {\pmod {35}}. Hint: From Fermat’s Little Theorem, a^{6} \equiv 1 {\pmod 7} and a^{4} \equiv 1 {\pmod 5}

(b) If gcd(a,42) =1, show that 168=3.7.8 divides a^{6}-1
(c) If gcd(a,133)=gcd(b,133)=1, show that 133| a^{18} - b^{18}

Question 8:

Show that 561|2^{561}-1 and 561|3^{561}-3. Do there exist infinitely many composite numbers n with the property that n|2^{n}-2 and n|3^{n}-3?

Question 9:

Prove that any integer of the form n = (6k+1)(12k+1)(18k+1) is an absolute pseudoprime if all three factors are prime; hence, 1729=7.13.19 is an absolute pseudoprime.

Question 10:

Prove that 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 {pmod 4}.

Note: By quadratic congruence is meant a congruence of the form ax^{2}+bx+c \equiv 0 {\pmod n} with a \equiv 0 {\pmod n}. This is the content of the above proof.

More later,
Nalin Pithwa.

Pre RMO algebra : some tough problems

Question 1:

Find the cube root of x^{3} -12x^{2} + 54x -112 + \frac{108}{x} - \frac{48}{x^{2}} + \frac{8}{x^{3}}

Question 2:

Find the square root of \frac{x}{y} + \frac{y}{x} +3 - 2\sqrt{\frac{x}{y}} -2\sqrt{\frac{y}{x}}

Question 3:

Simplify (a):

(\frac{x}{x-1} - \frac{1}{x+1}). \frac{x^{3}-1}{x^{6}+1}.\frac{(x-1)^{2}(x+1)^{2}+x^{2}}{x^{4}+x^{2}+1}

Simplify (b):
\{ \frac{a^{4}-y^{4}}{a^{2}-2ay+y^{2}} \div \frac{a^{2}+ay}{a-y} \} \times \{ \frac{a^{5}-a^{3}y^{2}}{a^{3}+y^{3}} \div \frac{a^{4}-2a^{3}y+a^{2}y^{2}}{a^{2}-ay+y^{2}}\}

Question 4:

Solve : \frac{3x}{11} + \frac{25}{x+4} = \frac{1}{3} (x+5)

Question 5:

Solve the following simultaneous equations:

2x^{2}-3y^{2}=23 and 2xy - 3y^{2}=3

Question 6:

Simplify (a):

\frac{1- \frac{a^{2}}{(x+a)^{2}}}{(x+a)(x-a)} \div \frac{x(x+2a)}{(x^{2}-a^{2})(x+a)^{2}}

Simplify (b):

\frac{6x^{2}y^{2}}{m+n} \div \{\frac{3(m-n)x}{7(r+s)} \div \{ \frac{4(r-s)}{21xy^{2}} \div \frac{(r^{2}-s^{2})}{4(m^{2}-n^{2})}\} \}

Question 7:

Find the HCF and LCM of the following algebraic expressions:

20x^{4}+x^{2}-1 and 25x^{4}+5x^{3} - x - 1 and 25x^{4} -10x^{2} +1

Question 8:

Simplify the following using two different approaches:

\frac{5}{6- \frac{5}{6- \frac{5}{6-x}}} = x

Question 9:

Solve the following simultaneous equations:

Slatex x^{2}y^{2} + 192 = 28xy$ and x+y=8

Question 10:

If a, b, c are in HP, then show that

(\frac{3}{a} + \frac{3}{b} - \frac{2}{c})(\frac{3}{c} + \frac{3}{b} - \frac{2}{a})+ \frac{9}{b^{2}}=\frac{25}{ac}

Question 11:

if a+b+c+d=2s, prove that

4(ab+cd)^{2} - (a^{2}+b^{2}-c^{2}-d^{2})^{2}= 16(s-a)(s-b)(s-c)(s-d)

Question 12:

Determine the ratio x:y:z if we know that

\frac{x+z}{y} = \frac{z}{x} = \frac{x}{z-y}

More later,
Nalin Pithwa

Those interested in such mathematical olympiads should refer to:

(I am a tutor for such mathematical olympiads).

Elementary Number Theory, ISBN numbers and mathematics olympiads

Question 1:

The International Standard Book Number (ISBN) used in many libraries consists of nine digits a_{1} a_{2}\ldots a_{9} followed by a tenth check digit a_{10} (somewhat like Hamming codes), which satisfies

a_{10} = \sum_{k=1}^{9}k a_{k} \pmod {11}

Determine whether each of the ISBN’s below is correct.
(a) 0-07-232569-0 (USA)
(b) 91-7643-497-5 (Sweden)
(c) 1-56947-303-10 (UK)

Question 2:

When printing the ISBN a_{1}a_{2}\ldots a_{9}, two unequal digits were transposed. Show that the check digits detected this error.

Remark: Such codes are called error correcting codes and are fundamental to wireless communications including cell phone technologies.

More later,
Nalin Pithwa.