Prime Numbers and Divisibility Rule
Prime Numbers and Divisibility Rule
DIVISIBILITY RULE
If a and b are integers and there is some integer c such
that a = b · c, then we say that b divides a or is a factor
or divisor of a and write b|a.
1
contradicts the assumption that there is are finitely many
primes, proving there are infinitely many.
2
Sieve of Erastothenes
3
Test for Primality
Goldbach’s Conjecture
4
Goldbach’s Conjecture is that every even integer
greater than 4 may be written as a sum of two odd
primes. Goldbach’s Conjecture has been shown to hold
for all even integers up to 400 trillion, but has not yet
been proven in general. Hence, it remains a conjecture
rather than a theorem*. Theorem (The Division
Algorithm). If a, b are integers with b > 0, then there
exist unique integers q, r such that a = q · b + r with 0 ≤ r
< b. q is called the quotient and r is called the remainder.
5
The Euclidean Algorithm gives a method (an algorithm!)
for finding the greatest common divisor of any two
positive integers:
Given a, b, we apply the Euclidean Algorithm and find
(a, b) = (b, r). We then apply the Euclidean Algorithm to
the pair b, r. We keep repeating the process, each time
getting a new pair of numbers with the same gcd as a,
b, until we get two numbers such that one divides the
other. That divisor is the gcd we’re looking for.
Modular Arithmetic
6
Definition (congruence) : If n is a positive integer, two
integers a, b are said to be congruent modulo n if they
both have the same remainder when divided by n. We
write a ≡ b mod n. Corollary. a ≡ b mod n if and only if n|
(a − b).
1. a + c ≡ b + d mod n
2. a − c ≡ b − d mod n
3. a · b ≡ b · d mod n
Divisibility Tests
7
A test for divisibility is called Casting Out Nines:
Theorem: A positive integer is divisible by 9 if and only if
the sum of its digits is divisible by 9.
o Proof. Since 10 ≡ 1 mod 9, it follows that 10n ≡ 1
mod 9 for any positive integer n. Given any integer
N, we may write N = am · 10m + am−1
·10m−1+am−2 ·10m−2+. . . a0 ·100, where a0, a1,
a2, . . . am are the digits in N. But then N ≡ am · 1 +
am−1 · 1 + · · · + a0 mod 9.
8
A variation gives a method called Casting out Elevens for
testing divisibility by 11. It’s based on the fact that 10 ≡
−1 mod 11, so 10n ≡ (−1)n mod 11.
o Theorem (Casting Out Elevens). A positive integer
is divisible by 11 if and only if the alternating sum
of its digits is divisible by 11.
9
Proof. Since 10 ≡ −1 mod 9, it follows that 10n ≡ (−1)n
mod 11 for any positive integer n. Given any integer N,
we may write N = am · 10m+am−1 ·10m−1+am−2
·10m−2+. . . a0 ·100 , where a0, a1, a2, . . . am are the
digits in N. But then N ≡ am ·(−1)m+am−1 ·(−1)m−1+· ·
·+a0 mod 11 ≡ a0 − a1 + a2 − a3 + · · · + (−1)mam
mod 11.
Other Tests
Divisibility By 2 – The units digit must be even.
Divisibility By 4 – The number formed by its last two
digits must be divisible by 4.
Divisibility By 5 – The units digit must be 0 or 5.
Divisibility By 6 – It must be even and divisible by 3.
10
Divisibility By 7 – When the units digit is doubled and
subtracted from the number formed by the remaining
digits, the resulting number must be divisible by 7. (To
verify, write the original number in the form 10a + b ≡
3a + b mod 7, so the resulting number is a − 2b, and
check the possible ways for 3a + b to be divisible by 7.)
Divisibility By 8 – The number formed by its last three
digits must be divisible by 8.
Divisibility By 10 – Its last digit must be 0.
Check Digits
12
UPC Number Check Digit Formula: a0 is chosen so
(3a11+a10+3a9+a8+3a7+a6+3a5+ a4 + 3a3 + a2 + 3a1) ≡ 0
mod 10.
13
Tournament Scheduling Problem:
How do we schedule the teams playing in a round-robin
tournament?
Solution:
Let N be the number of teams in the tournament and
number the teams 1, 2, 3, . . . , N.
Let Tm,r be the team which Team m plays in Round r.
If there is an odd number of teams, we let Tm,r be the
unique integer between 1 and N such that
Tm,r ≡ r − m mod N.
If Tm,r = m, then Team m gets a bye.
If there is an even number of teams, we schedule the
teams as if there was one fewer team and let the team
that would otherwise get a bye play the last team.
14
Cryptology
Definition (Cryptology). Cryptology is the discipline of
encoding and decoding messages.
15
The Caesar Cipher
The Caesar Cipher is one of the earliest known ciphers
and was used by Julius Casar. Each letter in a message is
simply replaced by the letter coming three letters after it
in the alphabet.
16
To decode, we could try to solve the congruence (1) for P in
terms of C. We might proceed as follows:
C ≡ aP + b mod 26,
aP ≡ C − b mod 26,
P ≡ a −1(C − b) mod 26.
Question: What is a^ −1, the multiplicative inverse of a?
It would have to be a number such that a·a −1 ≡ 1 mod 26.
It turns out that not all integers have such an inverse. For
example, no even numbers could have inverses mod 26 since
any multiple of an even number would be even and could
only be congruent to another even integer and thus could
not possibly be congruent to 1. Theorem 1. An integer a has a
multiplicative inverse mod n if and only if a and n have no
factors in common other than 1, in other words, if (a, n) = 1.
17
Hill Cipher
18