Integers

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 19

Topic : Integers

Subtopics: Binary, Hexadecimal and Base-n representation, Modulo operations,


Divisibility, GCD and LCD, the Euclidean algorithm, sequences, recurrence relations, finding
primes.
Division
Definition :
If a and b are integers with a ≠ 0, then a divides b if there exists an integer c such that b =
ac.
When a divides b we write a|b. We say that a is a factor or divisor of b and b is a multiple
of a.
If a|b then b/a is an integer (namely the c above).
If a does not divide b, we write aꭗb.
Theorem 1
Let a, b, c be integers, where a ≠ 0.
1 If a|b and a|c, then a|(b + c).
2 If a|b, then a|bc for all integers c.
3 If a|b and b|c, then a|c.
Division Algorithm
When an integer is divided by a positive integer, there is a quotient and a remainder. This is
traditionally called the “Division Algorithm”, but it is really a theorem.
Theorem 2
If a is an integer and d a positive integer, then there are unique integers q and r, with 0 ≤ r < d,
such that a = dq + r
a is called the dividend.
d is called the divisor.
q is called the quotient. q = a div d
r is called the remainder. r = a mod d
Example
Find 129div7 and 129mod7.
Solution
We have
129 = 7⋅18+3.

This implies that


129 div 7=18
and
129 mod 7=3(divisor ≡ modulus(mod)).
Congruence Relation

Definition
 If a and b are integers and m is a positive integer, then a is congruent to b modulo m iff m|
(a − b).
 The notation a ≡ b( mod m) says that a is congruent to b modulo m. We say that a ≡
b( mod m) is a congruence, and that m is its modulus.
 Two integers are congruent mod m if and only if they have the same remainder when
divided by m.
 If a is not congruent to b modulo m, we write a ≡/ b( mod m).
CONGRUENCE

Exercise 1
1. Determine whether 17 is congruent to 5 modulo 6, and whether 24 and 14 are
congruent modulo 6.

Terminology
The uses of “mod” in the following expressions are different.
a ≡ b( mod m), and
a mod m = b
a ≡ b( mod m) describes a binary relation on the set of integers.
In a mod m = b, the notation mod denotes a function (from integers to integers).
The relationship between these notations is made clear in this theorem.
Theorem 3.
Let a and b be integers, and let m be a positive integer.
Then a ≡ b( mod m) if and only if a mod m = b mod m

A Theorem on Congruences
Theorem 4.
Let m be a positive integer. The integers a and b are congruent modulo m if and only if there
is an integer k such that a = b + km.
Proof.
If a ≡ b( mod m), then (by the definition of congruence) m|(a − b).
Hence, there is an integer k such that a − b = km and equivalently a = b + km.
Conversely, if there is an integer k such that a = b + km, then km = a − b.
Hence, m|(a − b) and a ≡ b( mod m).
Congruences of Sums and Products
Theorem 5.
Let m be a positive integer. If a ≡ b( mod m) and c ≡ d( mod m), then a + c ≡ b + d( mod m)
and ac ≡ bd( mod m).
Proof.
Since a ≡ b( mod m) and c ≡ d( mod m), by the Theorem 4 above there are integers s and t
with b = a + sm and d = c + tm.
Therefore;
b + d = (a + sm) + (c + tm) = (a + c) + m(s + t), and
bd = (a + sm)(c + tm) = ac + m(at + cs + stm).
Hence, a + c ≡ b + d( mod m) and ac ≡ bd( mod m).
Corollary 5.1
Let m be a positive integer and let a and b be integers. Then (a + b) mod m =
((a mod m) + (b mod m)) mod m ab mod m = ((a mod m)(b mod m)) mod m.
Arithmetic modulo m
Let Zm = {0, 1, . . . , m − 1}.
The operation +m is defined as a +m b = (a + b) mod m. This is addition modulo m.
The operation ·m is defined as a ·m b = (a · b) mod m. This is multiplication modulo m.
Using these operations is said to be doing arithmetic modulo m.

Example:
1. Find 7 +11 9 and 7 ·11 9.
Solution:
Using the definitions above:
7 +11 9 = (7 + 9) mod 11 = 16 mod 11 = 5
7 ·11 9 = (7 · 9) mod 11 = 63 mod 11 = 8
Exercise 2
Find addition and multiplication tables for Z5

Arithmetic modulo m
The operations +m and ·m satisfy many of the same properties as ordinary addition and
multiplication.
Closure: If a, b ∈ Zm , then a +m b and a ·m b belong to Zm.
Associativity: If a, b, c ∈ Zm, then (a +m b) +m c = a +m (b +m c) and (a ·m b) ·m c = a ·m (b ·m c).
Commutativity: If a, b ∈ Zm, then a +m b = b +m a and a ·m b = b ·m a.
Identity elements: The elements 0 and 1 are identity elements for addition and multiplication
modulo m, respectively.
If a ∈ Zm then a +m 0 = a and a ·m 1 = a.
Additive inverses: If 0 =/ a ∈ Zm, then m − a is the additive inverse of a modulo m. Moreover, 0 is
its own additive inverse. a +m (m − a) = 0 and 0 +m 0 = 0.
Distributivity: If a, b, c ∈ Zm, then a ·m (b +m c) = (a ·m b) +m (a ·m c) and (a +m b) ·m c = (a ·m c) +m (b ·m
c).
Base b Representation of Integers
Theorem 6
Let b be a positive integer greater than 1. Every positive integer n can be expressed uniquely
in the form:
n = akbk + ak−1bk−1 + · · · + a1b + a0
where k is a nonnegative integer, a0, a1, . . . ak ∈ {0, . . . , b − 1} and ak =/ 0.
The a0, a1, . . . ak are called the base-b digits of the representation
.

This representation of n is called the base b expansion of n and it is denoted by (a kak−1 . . .


a1a0)b b = 2 is binary. b = 8 is octal. b = 10 is decimal. b = 16 is hexadecimal, etc.
Primes
Definition
A positive integer p > 1 is called prime iff the only positive factors of p are 1 and p. Otherwise it
is called composite ..

Theorem 7 (Fundamental Theorem of Arithmetic)


Every positive integer greater than 1 can be written uniquely as a prime or as the product of
its prime factors, written in order of nondecreasing size.
Examples
• 12 = 2*2*3
• 21 = 3*7
• 4 = 2*2
• 765 = 3 *3 * 5 *17 = 3 2 *5 *17
Exercise 3
Using contradiction proof that there are infinitely many primes.
Primes and composites
• How to determine whether the number is a prime or a composite?
Let n be a number. Then in order to determine whether it is a prime we can test:

• Approach 1: if any number x < n divides it. If yes, it is a composite. If we test all numbers
x < n and do not find the proper divisor, then n is a prime.
• Approach 2: if any prime number x < n divides it. If yes, it is a composite. If we test all
primes x < n and do not find a proper divisor, then n is a prime.
• Approach 3: if any prime number x < divides it. If yes, it is a composite. If we test all
primes x < and do not find a proper divisor, then n is a prime.
Exercise 4*
Discuss distribution of prime numbers.
Greatest Common Divisor
Definition
Let a, b ∈ Z − {0}. The largest integer d such that d|a and also d|b is called the greatest
common divisor of a and b. It is denoted by gcd(a, b).
A systematic way to find the gcd using factorization:
• Let a=p1 a1 p2 a2 p3 a3 … pk ak and b= p1 b1 p2 b2 p3 b3 … pk bk
• gcd(a,b)= p1 min(a1,b1) p2 min(a2,b2) p3 min(a3,b3) … pk min(ak,bk)

Examples:
• gcd(24,36) = ?
• 24 = 2*2*2*3=23*3
• 36= 2*2*3*3=22*32
• gcd(24,36) =22*3 = 12
Definition
The integers a and b are relatively prime (coprime) iff gcd(a, b) = 1

Exercise 5
Give three examples of relatively prime numbers.

Definition
The integers a1, a2, . . . , an are pairwise relatively prime iff gcd(ai , aj) = 1 whenever 1 ≤ i < j ≤
n. Example:
10, 17 and 21 are pairwise relatively prime, since gcd (10, 17) = gcd (10, 21) = gcd (17, 21) = 1.
Least Common Multiple
Definition
The least common multiple of the positive integers a and b is the smallest positive integer that is
divisible by both a and b. It is denoted by lcm(a, b).
A systematic way to find the lcm using factorization:
• Let a =p1 a1 p2 a2 p3 a3 … pk ak and b = p1 b1 p2 b2 p3 b3 … pk bk
• Lcm(a,b)= p1 max(a1,b1) p2 max(a2,b2) p3 max(a3,b3) … pk max(ak,bk)
Example:
• What is lcm(12,9) =?
• 12 = 2*2*3=22*3
• 9=3*3 =32
• Lcm(12,9) = 22 * 32 = 4 * 9 = 36
Factorization is a very inefficient method to compute gcd and lcm. The Euclidian algorithm is much better.

Euclidian Algorithm
Lemma
Let a = bq + r, where a, b, q, and r are integers. Then gcd(a, b) = gcd(b, r).

Assume two numbers 287 and 91. We want gcd(287,91).


• First divide the larger number (287) by the smaller one (91)
• We get 287 = 3*91 +14
(1) Any divisor of 91 and 287 must also be a divisor of 14:
• 287 - 3*91 = 14
• Why? [ ak – cbk] =r  (a-cb)k = r  (a-cb) = r/k (must be an integer and thus k divides r ] (2)
Any divisor of 91 and 14 must also be a divisor of 287
• Why? 287 = 3 b k + dk  287 = k(3b +d)  287 /k = (3b +d)  287/k must be an integer
• But then gcd(287,91) = gcd(91,14)
We know that gcd(287,91) = gcd(91,14)

• But the same trick can be applied again:


• gcd(91,14)
• 91 = 14.6 + 7
• and therefore – gcd(91,14)=gcd(14,7)
• And one more time: – gcd(14,7) = 7 – trivial
• The result: gcd(287,91) = gcd(91,14)=gcd(14,7) = 7
Example 1:
• Find the greatest common divisor of 666 & 558
• gcd(666,558) 666=1*558 + 108
= gcd(558,108) 558=5*108 + 18
= gcd(108,18) 108=6*18 + 0
= 18
Example 2:
• Find the greatest common divisor of 286 & 503:
• gcd(503,286) 503=1*286 + 217
=gcd(286, 217) 286=1*217 + 69
=gcd(217, 69) 217 = 3*69 + 10
= gcd(69,10) 69 = 6*10 + 9
=gcd(10,9) 10=1*9 + 1
= gcd(9,1) =1
Linear Congruences
Definition
A congruence of the form ax ≡ b( mod m) where m is a positive integer, a, b are integers and x is an
integer variable is called a linear congruence.

The solution of the congruence are all the integers x that satisfy it.
Definition
An integer a such that aa¯≡ 1( mod m) is called a multiplicative inverse of a modulo m .

Multiplicative inverses can be used to solve congruences.


If ax ≡ b( mod m) then a¯ax ≡ (a¯b)( mod m) and thus x ≡ (a¯b)( mod m).

Multiplicative Inverses

Example:
Let m = 15. Find a multiplicative inverse of 8 modulo 15.

2 · 8 = 16 ≡ 1( mod 15).
Thus 2 is a multiplicative inverse of 8 modulo 15.
Exercise 6
Find a multiplicative inverse of 7 modulo 15.
What is the multiplicative inverse of 5 modulo 15?

You might also like