CSCI 2824: Lecture 7

In this lecture we will cover:

  1. Divisibility of numbers and modular arithmetic.

  2. Some proofs involving divisibility.

Topics covered: Chapter 2.2 of the book.

Proving Properties of Numbers

Let us start with divisibility.

An integer n is divisible by a non-zero integer k, if n can be written as n = k times q for some integers k and q. In logic, we write:

 mbox{isDivisible}(n,k): k not= 0 mbox{AND} (exists q in mathbb{Z} n = k times q ) ,.

The following concepts are all equivalent:

  • n is divisible by k

  • k divides n,

  • k is a factor of n,

  • n mod k = 0, and

  • n is a multiple of k.

Divisibility by 2 has a special name: If n is divisible by 2, we call it even, and other wise we call it odd.

Theorem -1: If m,n are divisible by 3 then m times n is divisible by 9.


For your convenience, we split the proof step by step to make the flow of reasoning steps clear.

  1. Let m,n be any two given numbers such that m ,n are divisible by 3.

  2. Therefore, we write m = 3 k, for some integer k.

  3. And, since n is divisible by 3, n= 3 l for some integers l.

  4. We note that m n = 3k times 3l = 9 kl.

  5. Therefore mn is divisible by 9.

Important Note

Whenever in a proof, a number can be written as  n = 7 cdot m, we conclude that n is divisible by 7. Similarly, if you are told that a number is divisible by 7, it makes sense to write it as n = 7 l for some l.

Theorem-2 If n is divisible by 5 and m by 3 then m^2 times n is divisible by 45.

  1. Let m,n be any given numbers such that 5 divides n and 3 divides m.

  2. Therefore, we write n = 5K for some integer K, and

  3. m = 3L for some integer L.

  4. The number m^2 n may be written as:  m^2 n = (3L)^2 5 K = 9 L^2 5 K = 45 L^2 K.

  5. Therefore m^2n is divisible by 45.

Proofs on Consecutive Numbers

Theorem-3 The product of two consecutive numbers is always even.

  1. Let n be any given number and n+1 be the next consecutive numbers.

  2. We will show that n(n+1) is even.

  3. We note that there are two cases based on whether n is odd or even.

    • Case-1: n is odd. In this case, we have n+1 being even. Therefore n(n+1) = ODD * EVEN which is EVEN.

    • Case-2: n is even. In this case n(n+1) is even too.

  1. In either case, n(n+1) is even. QED.

Proofs by Case-Splitting

A number n in mathbb{N} is a perfect square if n = m^2 for some m in mathbb{N}. Examples of perfect squares include 1,4,9,16,225, 1600 and so on.

Theorem-4 If a perfect square is even, then it is divisible by 4.

  1. Let n be any given perfect square that is even.

  2. Since n is a perfect square, can be written as n=m^2 for some m.

  3. We consider two cases based on whether m is odd or even.

  • Case-1: m is odd.

    1. In this case, we know that m times m is a product of two odd numbers is odd.

    2. However, this conflicts with our assumption that n = m*m is even.

    3. Therefore, this case can never happen.

  • Case-2: m is even.

    1. In this case, m = 2k for some integer k.

    2. n = m^2 = 4 k^2 is divisible by 4.

Therefore, we conclude that n must be divisible by 4 based on case 2, which is the only case that can happen.


There are other ways of proving this theorem that we will revisit when we study proofs by contradiction.

Modular Arithmetic

We have been using the “mod” operator so far in some proofs. Let us study the properties of the “mod” operator in more detail.

Modulo Operator

Let n be some integer. For a integer k > 0 say that n mod k = r iff  n can be written as  n = k q + r where q is the quotient and r is the remainder when n is divided by k.

Let us look at examples.


We write  15 mod 7 = 1. Since 15 = 2 * 7 + 1.

As a convention, the result of a modulo operation  a mod b is always between 0 and b -1.

Also, we always apply over b positive, but a can be positive or negative What is -22 mod 5? We write -22 = -5 * 5 + 3. Therefore -22 mod 5= 3.


  • n mod 0 is undefined.

  • We will not bother defining n mod k for negative k.

  • We will only apply mod to integers for now. It can be defined on reals but that is not very important to us now.

Odd number: A number n is odd iff n mod 2 = 1.

We can distribute mbox{mod} over +,*.

 (m + n) mod k = ((m mod k) + (n mod k))mod k


 (m cdot n) mod k = ( (m mod k) cdot (n mod k) ) mod k

Let us prove these facts:

Theorem: Suppose number n can be written as n = a k + b for k > 0. It follows that n mod k = b mod k.


Let b mod k = r. Therefore b = k q + r for some q. Note that  0 leq r < k.

 n = (ak + b) = (ak + kq) + r  = (k (a+q) + r)

Therefore n can be written as  (a+q)k +r for 0 leq r < k. We conclude therefore that a+q is the quotient when n is divided by k and r is the remainder. Therefore,

 n mod k = r


Theorem: For any integers m,n and integer k > 0, the following statement is true:

 (m + n) mod k = ((m mod k) + (n mod k))mod k


Let us assume m mod k = r_1 and n mod k = r_2. Therefore, we may write m as m = k q_1 + r_1 for some q_1. We also write n as n = k q_2 + r_2 for some q_2.

Therefore, m + n = k q_1 + k q_2 + r_1 + r_2 .

 m + n mod k = k (q_1 + q_2) + (r_1 + r_2) mod k = (r_1 + r_2) mod k  = (m mod k + n mod k) mod k


Similarly, we can prove that modulo operator distributes over multiplication.

Theorem For any integers m,n, and natural number k > 0, the following statement is true:

 (m times n) mod k = (( m mod k) times (n mod k)) mod k


Let m mod k = r_1 and n mod k = r_2, where 0 leq r_1 < k and 0 leq r_2 < k. We can write

 m = k q_1 + r_1 and n = k q_2 = r_2.

Therefore, using the distributivity of modulo operator over addition (proved in the previous theorem),

 m times n = (k q_1 + r_1) times (k q_2 +r_2) = k^2 q_1 q_2 + k q_1 r_2 + k q_2 r_1 + r_1 r_2


 begin{array}{rcl} (m times n ) mod k & =&  (k^2 q_1 q_2 mod k) + (k q_1 r_2 mod k) + (k q_2 r_2 mod k) + (r_1 r_2 mod k)  & =& r_1 r_2 mod k end{array}

This shows that

 (m times n) mod k = (( m mod k) times (n mod k)) mod k


Computing modulo

Let us try some interesting problems involving modulo arithmetic.

Example 1

For instance, let us try and compute 10^n mod 11 for various values of n.

  • 10^1 mod 11 = 10

  • 10^2 mod 11 = 1

  • 10^3 mod 11 = 10

  • begin{array}{rcl} 10^4 mod 11 &=& ( (10^3 mod 11) times (10 mod 11) ) mod 11  &=& (10 times 10) mod 11 = 1 end{array}.

As you can see the pattern that emerges is

  • 10^{n} mod 11 = 1 if n is even.

  • 10^n mod 11 = 10 if n is odd.

Example 2

We know 1000! is a really large number. The question is very simple. Suppose we wrote 1000! in hexadecimal, what would the last digit be?

In general, the last digit of a number n in hexadecimal is simply computed by finding out n mod 16. So what is 1000! mod 16?


 1000! mod 16 = 0, because 1000! = 1 times 2 times cdots times 16 times cdots times 1000 = 16 n for some n in mathbb{N}.

Example 3

Find the smallest natural number that leaves a remainder of 2 when divided by 3 and a remainder of 5 when divided by 7.

Let our mystery number be n. We require n mod 3 = 2. Therefore, n = 3k +2 for some k.

Now consider nmod 7 = (3k + 2) mod 7 = (3 times (k mod 7) + 2 ) mod 7 = 5.

Therefore, we note that 3 times (k mod 7) = 3 mod 7 or in other words k mod 7 = 1 and k = 7l +1 for some l.

Let us choose l= 0 to yield k = 1 and therefore n = 5.

The smallest number is indeed n = 5.

We will examine more problems of this sort when we look at the Chinese remainder theorem.