You are on page 1of 16

Basics of Number Theory

Waleed Bin Shahid


waleedbinshahid@gmail.com
Prime Numbers
Definition: An integer p>1 is said to be prime if its only
positive
divisors are 1 and p. An integer greater than 1 that is not
prime is
• 2, 3, 5, 7 … are
called Composite
primes
• 4,6,8,9,10,… are
composites
• 2 is the only even prime
• 1 is neither prime nor
composite
Fundamental Theorem of Arithmetic: Every
positive
integer n>1 can be expressed as a product of
primes; this
representation is unique, apart from the order in which th
factors
occur
Congruence
Congruence
Definition
Let n be a fixed positive integer. Two integers a and b are said to
becongruent modulo n, symbolizeda  b modn if n divides the
by
difference a-b.
3  24 mod7, − 31  11 mod7, − 15  −64

mod 7
Given an integer a, let q and r be its quotient and remainder
upon
division by n, so that a qn r n
r by definition of
Then = a+ r, (mod
0  n)
congruence,
 Every integer is congruent modulo n to exactly one of the values
0, 1,
…, n-1 and in a  0 (mod n) iff n |
particular
a
Modular Exponentiation
Modular Exponentiation
Fermat’s Little Theorem
Let p be a prime and suppose that p | a
Then
p−1
a  1 mod p
Divisibility Algorithm
• We say that a nonzero b divides a if a = mb for some m, where a, b,
and m are integers. That is, b divides a if there is no remainder on
division. The notation b | a is commonly used to mean b divides a.
Also, if b | a , we say that b is a divisor of a

• Subsequently, we will need some simple properties of divisibility for


integers, which are as follows
..contd
Division Algorithm
• Given any positive integer n and any nonnegative integer a, if
we divide a by n, we get an integer quotient q and an integer
remainder r that obey the following relationship
Euclidean Algorithm
• One of the basic techniques of number theory is the Euclidean
algorithm, which is a simple procedure for determining the greatest
common divisor of two positive integers

• First, we need a simple definition: Two integers are relatively prime


if their only common positive integer factor is 1

• Positive integer c is said to be the greatest common divisor of a and


b if
• c is a divisor of a and of b.
• Any divisor of a and b is a divisor of c.
• gcd(60, 24) = gcd(60, -24) = 12
Example
• The divisors of 12 are 1, 2, 3, 4, 6, 12
• The divisors of 30 are 1, 2, 3, 5, 6, 10, 15, 30
• Hence the common divisors of 12 and 30 are 1, 2, 3, 6
• Therefore gcd(12, 30) = 6
• Gcd(8,17) =
• Gcd(-5,5) =
• Gcd(-8,-36) =
..contd
..contd
• For example, for a = 329 and b = 182, we compute

329 = 1 · 182 + 147


182 = 1 · 147 + 35
147 = 4 · 35 + 7
35 = 5 · 7
and stop when there is no remainder. The last dividend is the
gcd, so in our example, gcd(329,182) = 7.
..contd
• a = 267, b = 207, the Euclidean Algorithm produces the
following quotients and remainders.
267 = 1 X 207 + 60
207 = 3 X 60 + 27
60 = 2 X 27 + 6
27 = 4 X 6 + 3
6 = 2X3+0

The last non-zero remainder is 3, so gcd(267; 207) = 3. Back-


substitution gives:

You might also like