PMC Number Theory

You might also like

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

n m

Panolong Mathletes Club – PRIME Training


(Elementary) Number Theory
Compiled by Naseb S. H.Ali

FUNDAMENTALS

 FUNDAMENTAL THEOREM OF ARITHMETIC – Every positive integer n>1 is either a prime or a product of primes; this
representation is unique, apart from the order in which the factors occur.

 PARITY – the parity of a number depends only on its remainder after dividing by 2. An even number has a parity 0 because the remainder
after dividing by 2 is 0, while an odd number has a parity 1 because the remainder after dividing by 2 is 1.
1. EVEN ± EVEN=EVEN
2. ODD ±ODD=EVEN
3. EVEN ± ODD=ODD
4. EVEN × EVEN =EVEN
5. EVEN ×ODD=EVEN
6. ODD ×ODD=ODD
 PRIME FACTORIZATION – a divides b iff the exponents of the prime factors of a are less than or equal to the exponents of the
corresponding prime factors of b
 PRIMALITY TESTING – to test the positive integer a to see if its prime, we only need to check to see if it is divisible by the primes p such
that p2 ≤a .
 NUMBER OF DIVISORS / TAU FUNCTION – to find the number of positive divisors of a positive whole number n :
1. Write n as a product of prime powers
2. Add one to each of the exponents of the primes
3. Multiply these new exponents together
e e e
i.e. if n= p11 . p 22 … pk k is the prime factorization of n , then n has ( e 1 +1 ) ( e 2+1 ) … (e k + 1) positive divisors.
τ ( n )=( e 1+ 1 )( e2 +1 ) …(ek +1)
 SUM OF ALL DIVISORS – To find the sum of all of the divisors of a positive integer:
1. Write n as a product of prime powers
2. Compute the sum of all powers of each prime (from zero up to exponent inclusive)
3. Multiply these sums together

i.e. n= pe1 . p e2 … pek is the prime factorization of n , then the sum of the divisors of n
if 1 2 k
is

(1+ p1 + p21 +…+ pe1 )(1+ p2 + p22 +…+ p2e )(1+ p k + p 2k +…+ pek ). Note that these factors can be computed using geometrics series
1 2 k

p e +1 −1 pe2 +1−1 pek +1 −1 1 2 k

formula from equation below, so the sum of the divisors of n is also σ ( n )= 1 . …


p1 −1 p2−1 pk −1

τ ( n)
 PRODUCT OF DIVISORS : τ ( n)
√n =n 2

 PRODUCT OF TWO COPRIME DIVISORS: 2n−1 , where n is the number prime divisor in pa1 . p b2 … pkn

SQUARES, CUBES, POWER OF TWO, DECIMAL REPRESENTATION OF FRACTIONS, APPROX. OF √ n, PYTHAGOREAN TRIPLES AND
YEAR PRIME FACTORIZATION
n n2 n3 2n n! n n2 frac dec frac dec
1 1 1 1 1 11 121 1/2 0.5 5/6 0.8 3́ ¿ . of √ n
2 4 8 2 2 12 144 1/3 0. 3́ 1/7 0. 142857 ´ √ 2 ≈1.414
3 9 27 8 6 13 169 2/3 √ 3 ≈ 1.732
4 16 64 16 24
0. 6́ 1/8 0.125
14 196
5 25 125 32 120 15 225 1/4 0.25 3/8 0.375 √ 5 ≈ 2.236
PythagoreanTriples 64
6 36 216 720 16 256 3/ 4 0.75 5/8 0.625 √ 6 ≈ 2.499
a 7 49b 343 c 128 5040 17 289 1/5 0.2 7 /8 0.875 √ 7 ≈ 2.646
3 8 64 4 512 5 256 18 324 2/5 0.4 1/9 0. 1́ √ 10 ≈ 3.162
5 9 8112 72913 512 19 362 3/5 0.6 1/10 0.1 √ 11 ≈ 3.317
7 10 100
24 25 1024
8
1000
15 17
20 400 4 /5 0.8 1/12 0.08 3́
9 40 41 Prime Factorization Fraction Decimal
11 60 61
12 35 37 1991=11∗181 2010=2∗3∗5∗67
x /7 ´
0. 142857∧cycles
13 84 85 2000=24∗53 x /112∗503
2012=2 0. [9´x ]
16 63 65 1
20 21 29 2001=3∗23∗29 2013=3∗11∗61
x /9 0. [ ´x ]
28 45 53 2002=2∗7∗11∗13 2014=2∗19∗53
PRIME NUMBERS
2 3 5 7 11 13 17 19 23 29 31
n−1 37 41 43 47 53 59 61 67 71 73 79
 If pn is the nth power number, then pn ≤22 . 83 89 97 101 103 107 109 113 127 131 139
n 149 151 157 163 167 173 179 181 191 197 199
 For n ≥ 1, there are at least n+1 primes less than 22 . 211 223 227 229 233 239 241 251 257 263 269
 TWIN PRIME/GOLDBACH CONJENCTURE – is a 271 277 281 283 293 307 311 313 317 331 337
pair of primes ( p , q) such that q= p+2. It states that 347 349 353 359 367 373 379 383 389 397 401
there are infinitely many twin prime pairs. 409 419 421 431 433 439 443 449 457 461 463
467 479 487 491 499 503 509 521 523 541 547
557 563 569 571 577 587 593 599 601 607 613
617 619 631 641 643 647 653 659 661 673 677

RECOGNIZING PATTERNS OF UNITS DIGITS


digits d d2 d3 d4 d5
1 1 1 1 1
2 4 8 6 2
3 9 7 1 3
4 6 4 6 4
5 5 5 5 5
6 6 6 6 6
7 9 3 1 7
8 4 2 6 8
9 1 9 1 9
From the table, we can see the following:
The last digit of powers of 1 is always 1
The last digits of powers of 2 repeat in a cycle of 4, 8, 6, 2
The last digits of powers of 3 repeat in a cycle of 9, 7, 1, 3
The last digits of powers of 4 repeat in a cycle of 6, 4
The last digit of powers of 5 is always 5
The last digit of powers of 6 is always 6
The last digits of powers of 7 repeat in a cycle of 9, 3, 1, 7
The last digits of powers of 8 repeat in a cycle of 4, 2, 6, 8
The last digits of powers of 9 repeat in a cycle of 1, 9
The set of last digits of power forms a periodic sequence with periods given by the table below:
Digit Period
0, 1, 5, 6 1
2, 3, 7, 8 4
4, 9 2

GREATEST COMMON FACTOR AND LEAST COMMON MULTIPLE

1. Let the prime factorizations of two integers a , b be


a= pe1 pe2 … p ek
1 2 k

b= pf1 pf2 … pfk


1 2 k

2
The exponent above can be zero and the pi’s are distinct. Then,
o To get the prime factorization of gcd(a,b) write down the prime factorizations of a,b and take the least power of
each prime that appears in both
min (e 1 ,f 1) min ( e2 , f 2 ) min (e k ,f k )
gcd ( a ,b )= p1 p2 … pk
o To get the prime factorization of lcm(a,b) write down the prime factorizations of a,b and take the largest power
of each prime that appears in either
max (e 1 ,f 1) max ( e2 , f 2) max ( e k ,f k )
lcm [ a , b ] = p1 p2 … pk
2. lcm(a,b) gcd(a,b) = ab
3. gcd ( a ,b ,c ) lcm ( ab , bc , ac )=abc
4. gcd ( ca , cb )=c ∙ gcd ( a , b )
5. lcm(a,b,c)=x, then d, e, f | x , which lcm(a,b)=d, lcm(b,c)=e, and lcm(c,a)=f
6. If gcd(a,b) = 1 then ab - a - b is the largest integer which cannot be written in the form as + bt for some integers s ≥ 0, t ≥ 0.
7. Given integers a and b, not both of which are zero, there exist integers x and y such that

gcd ( a ,b )=ax +by


8. Two integers a and b, not both of which are zero, are said to be relatively prime / coprime whenever gcd(a,b)=1
9. Let a and b be integers, not both zero. Then a and b are relatively prime iff there exist integers x and y such that 1= ax+by
10. If gcd(a,b)=d, then gcd(a/d,b/d)=1
11. If a|c and b|c , with gcd(a,b)=1, then ab|c
12. EUCLID’S LEMMA – If a∨bc and gcd ( a ,b )=1, then a∨c

DIVISIBILITY
 Divisibility Test
A positive integer N is
If:
divisible by:
2 if the last digit of N is 2, 4, 6, 8, or 0
3 if the sum of digits of N is a multiple of 3
4 if the last 2 digits of N are a multiple of 4
5 if the last digit of N is either 0 or 5
6 if N is divisible by both 2 and 3
if subtracting twice the last digit of N from the remaining digits gives a multiple of 7 (e.g. 658 is divisible by 7 because 65 - 2 x 8 =
7 49, which is a multiple of 7)
8 if the last 3 digits of N are a multiple of 8
9 if the sum of digits of N is a multiple of 9
10 if the last digit of N is 0
if the difference of the alternating sum of digits of N is a multiple of 11 (e.g. 2343 is divisible by 11 because 2 - 3 + 4 - 3 = 0, which
11 is a multiple of 11)
12 if N is divisible by both 3 and 4
if 4 times the units digit of N plus the number obtained by removing the units digit of N is a multiple of 13
13

if the units digit subtracted 5 times from the remaining number (excluding the units digit) results in a number that is divisible by 17
17

if doubling the units digit and adding it to the number formed by removing the units digit in the original number is divisible by
19 19
Add 7 times the last digit to the remaining truncated number. Repeat the step if necessary. If the result is divisible by 23, the
original number is also divisible by 23.
23 - Check for 53935:  5393+7×5=5428⟹542+7×8=598⟹59+7×8=115, which is 5 times 23. Hence 53935 is divisible by 23.

Add 3 times the last digit to the remaining truncated number. Repeat the step if necessary. If the result is divisible by 29, the original
number is also divisible by 29.
29
 Check for 12528:  1252+3×8=1276⟹127+3×6=145⟹14+3×5=29, which is divisible by 29. So 12528 is divisible by 29.

Subtract 3 times the last digit from the remaining truncated number. Repeat the step if necessary . If the result is divisible by 31,
the original number is also divisible by 31.
31  Check for 49507: .4950−3×7=4929⟹492−3×9=465⟹46−3×5=31. Hence 49507 is divisible by 31.

3
Subtract 11 times the last digit from the remaining truncated number. Repeat the step if necessary. If the result is divisible by 37,
the original number is also divisible by 37.
37  Check for 11026: We have 1102−11×6=1036. Since 103−11×6=37 is divisible by 37, 11026 is divisible by 37.

Subtract 4 times the last digit from the remaining truncated number. Repeat the step if necessary. If the result is divisible by 41, the
original number is also divisible by 41.
41
 Check for 14145: We have 1414−4×5=1394. Since 139−4×4=123 is divisible by 41, 14145 is divisible by 41.

Add 13 times the last digit to the remaining truncated number. Repeat the step if necessary . If the result is divisible by 43, the
original number is also divisible by 43. (This process becomes difficult for most of the people because of multiplication with 13.)
43  Check for 11739: We have 1173+13×9=1290. Since 129 is divisible by 43, the 0 can be ignored. So, 11739 is divisible by 43.

Subtract 14 times the last digit from the remaining truncated number. Repeat the step if necessary. If the result is divisible by 47,
the original number is also divisible by 47. (This too is difficult to operate for people who are not comfortable with table of 14.)
 Check for 45026: We have 4502−14×6=4418. Since 441−14×8=329, which is 7 times 47, 45026 is divisible by 47.
47

 EUCLID’S DIVISION LEMMA/THE DIVISION AGORITHM – for any j and k with k > 0, there exist unique integers q and r such that
j=qk +r and 0 ≤ r <k . The integersq∧r are called, respectively, the quotient and remainder in the division of j∧k .
o Let m and n be integers such that m=qn+ r , where 0 ≤ r <n . Then

gcd ( m, n )=gcd ⁡( n ,r )
 EUCLIDEAN ALGORITHM – Let a∧b be two integers whose greatest common divisor is desired. Because gcd (|a|,|b|)=gcd ⁡( a .b),
ther is no harm in assuming that a ≥ b>0. The first step is to apply the Division Algorithm to a∧b to ge

a=q 1 b+ r 1 0 ≤ r 1< b
If it happens that r 1=0, then b|a and gcd ( a ,b )=b . When r 1 ≠0 , divide b by r 1 to produce integers q 2∧r 2satisfying
b=q 2 r 1 +r 2 0 ≤r 2 <r 1
If r 2=0, then we stop; otherwise, proceed as before to obtain

r 1=q3 r 2+ r 3 0≤ r 3 <r 2
This division process continues until some zero remainder appears, say, at the ( n+1 ) th stage where r n−1 is divided by r n (a zero remainder
occurs sooner or later because the decreasing sequence b> r 1 > r 2 > … ≥0 cannot contain more than b integers).

The result is the ff. system of equations:

a=q 1 b+ r 0 ≤ r 1 <b
b=q 2 r 1 +r 2 0 ≤r 2 <r 1
r 1=q3 r 2+ r 3 0≤ r 3 <r 2

r n−2=qn r n−1 +r n 0≤ r n <r n−1
r n−1=qn +1 r n +0
We argue that r n , the last nonzero remainder that appears in this manner, then we have

gcd ( a ,b )=gcd ( b , r 1 )=gcd (r 1 , ¿ r 2)=…=gcd ( r n−1 , r n )=r n ¿


 DIVISION ALGORITHM INVOLVING POLYNOMIALS – For two polynomials, a ( x ) ,b ( x ) ∈Q [ x ] , there is a unique quotient and
remainder polynomial, q (x) and r ( x ), such that

a ( x )=b ( x ) q ( x )+ r ( x ) , deg ( r ) <deg ( b )∨r ( x )=0


o If a ( x ) =b ( x ) q ( x )+ r (x) with deg ( r ( x ) ) <deg ( b ( x ) ) , then

gcd ( a ( x ) , b ( x ) )=gcd ( b ( x ) , r ( x ) ) .
 For natural numbers a , m , n , gcd ( a −1, a −1 )=agcd ( m , n) −1
m n

4
 EUCLIDEAN ALGORITHM (SIMPLE) - Note a∨b iff gcd ( a ,b )=a . We have gcd ( a ,b )=gcd ( a−b ,b )
DIOPHANTINE EQUATION
 LINEAR DIOPHANTINE EQUATION ax +by=c
o When c=0 ,then

 ax=−by and gcd ( a ,b )=1, which there is an existing value of x=bx ' and y=a y ' , or x ' =− y ' =k for
some common value of k . Thus the solutions of the system are given by ( b x ' ,a y ' )=(bk ,−ak ) for all integers
k.
o When c ≠ 0 ,

 The gcd (a , b) must divide c, or gcd ( a ,b )=1, then the specific solution of the equation ax +by=c is
c−ar
(
( x0 , y0)= r , b )
where r is any solution of ar ≡ c( mod b)
 ie. Find all possible values of 88

 FROBENIUS’ POSTAGE STAMP PROBLEM – if gcd ( a ,b )=1, for nonnegative x , y , the number of positive integers that can’t be
( ab−a−b ) +1 1
written as ax +by is = ( a−1 )( b−1 ) .
2 2
o If a and b are coprime, exactly half of the integers between 0 and gcd (a , b) are representable. So there
( ab−a−b ) +1 ( a−1 ) ( b−1 )
are  = non-representable positive integers.
2 2
 CHICKEN MCNUGGET THEOREM - Suppose a , b are relatively prime. Then the greatest integer that cannot be written in the form
ax +by (the greatest number that cannot be expressed as a sum of the two numbers) is ab−a−b .

 DIOAPHANTUS’ IDENTITY (BRAHMAGUPTA-FIBONACCI IDENTITY) – If two positive integers are each the sum if two squares (
m=a2+ b2 , n=c 2 +d 2 ¿. Then their product is the sum of two squares
( a 2+ b2 ) ( c 2+ d 2 )=( ac ±bd )2 + ( ad ∓ bc )2 .
 BÉZOUT’S IDENTITY - Suppose a∧b are integers. Mathematically, a ϵ Z and b ϵ Z . Then the Diophantine equation
ax +by=gcd ( a ,b) has a solution.
o In particular, if a∧b are relatively prime integers, we have gcd ( a ,b )=1 and by Bezout’s indentity, there are integers
x∧ y such that ax +by=1

 GENERAL BEZOUT’S IDENTITY – For integers a 1 , a2 , … , an, there exists integers x n , x 2 , … , x n such that
n
a 1 x 1+ a2 x 2 +…+ an x n=∑ ai xi =¿ gcd ( a 1 , a2 , … , an ) . ¿
i=1
 PYTHAGOREAN TRIPLES – All positive integer solutions to the equation a 2+b 2=c 2are given by:

a=k ( m2−n 2 )
b=k ( 2 mn )
c=k (m2 +n2 )
Where m , n ,∧k are arbitrary positive integers, with m>n. For relatively prime triples (a , b , c ), we need k =1, and m and n relatively
prime and of opposite parity.
 Without k constant;
a=m2−n2
b=2 mn
c=m2 +n 2

5
 When n=1 and m is a prime;
a=m 2−1
b=2 m
c=m2 +1

 FERMAT’S “LAST THEOREM” for n ≥ 3: The equation a n+ bn=cn has no solutions in integers unless abc=0.

 PELL’S EQUATION- is the equation

x 2−D y 2=± 1,

Where D is a nonsquare positive integer and x , y are integers. It can be shown that there are infinitely many solutions to the
equation.
 Suppose Pell’s equation has a nontrivial solution for D . Let ( x , y ) be the fundamental solution, i.e. the solution
with the smallest possible positive values x and y . Then every solution to Pell’s equation in positive integers is
generated by ( x , y ) .
 The solutions to the Pell equation when D is not a square turn out to be closely connect to the continued fraction
expansion of √ D . In fact, if a is the of the continued fraction (refer to page) and C k =Pk /Q k is the k th convergent,
then all solutions to the Pell equation x 2−D y 2=± 1 are given by ( x , y ) =(Pia ,Q ia) , for all positive integers i .
 i.e. Find all possible solutions of x 2−3 y 2=± 1.
1
1+
1
1+
 The continued fraction expansion for √ 3 is 1 ,
2+
1
1+
2+…
1 2 5 7
And the first few convergents can easily be calculated as , , , . Since the period is 2, we expect thst the
1 1 3 4
second and fourth convergents will yield solution to x 2−3 y 2=± 1: ( 2,1 ) and (7,4) can be verified to work. On
the other hand, the first and third convergents will not yield solutions: you can verify that ( 1,1 ) and (5,3) are not
solutions.

o BRAHMAGUPTA’S IDENTITY

( x 2−n y 2 ) ( a2 −n b2 )= ( xa +nyb )2−n ( xb + ya )2

MODULAR ARITHMETIC / CONGRUENCY

 DEFINITION: Let n be a fixed positive integer. Two integers a∧b are said to be congruent modulo n, symbolized by

a ≡ b(mod n)
if n divides the difference a−b ; that is, provided that a−b=kn for some integer k .

 DEFINITION 2: Parametric expressions give us another way to tell when two integers are congruent in a given modulus;

For any integers a and b , a ≡ b(mod n) iff

a=q 1 m+r
b=q 2 m+r
Where q 1 , q 2and r are integers and 0 ≤ r <m.

6
 DEFINITION 3 [ INVERSION ]: We say that the inverse of a number a modulo m when a and m are relatively prime is the number b such
that ab ≡ 1(mod m) .

o eg. The inverse of 3 mod 4 is 3 because 3 ∙3=9 ≡1 ( mod 4 ) . The inverse of 3 mod 5 is 2 because 3 ∙2=6 ≡1 ( mod 5 ) .
 * The ff theorem is incredibly important and helps us to solve Euler’s Totient Theorem and Chinese Remainder
Theorem.
o When gcd ( a ,m )=1 , a always has a distinct inverse mod m .
o The equation ax ≡b (mod m) always has a solution when gcd ( a ,m )=1.

 ADDITION AND MULTIPLICATION PROPERTY OF CONGRUENCY - If a ≡ x ( mod n) and b ≡ y (mod n) then


( x + y ) mod n≡ ( a+b ) mod n
( xy ) mod n ≡ ( ab ) mod n

 All of the divisibility tests above can also be used to compute the remainder (except for 6). For n mod 11, remember that 1 ≡1(mod 11) and
10 ≡−1(mod n) (so you know which digit sum to subtract). To compute n mod 6 , add the rightmost digit to 4 times the sum of remaining
digits and then compute the total mod 6.

 Let n>1 be fixed and a , b , c , d be arbitrary integers. Then the following properties hold:
a) a ≡ a ( mod n )
b) If a ≡ b ( mod n ) , then b ≡ a ( mod n ) .
c) If a ≡ b(mod n) and b ≡ c ( mod n ) , then a ≡ c ( mod n ) .
d) If a ≡ b(mod n) and c ≡d (mod n) , then a+ c ≡ b+d (mod n) and ac ≡bd ( mod n ) .
e) If a ≡ b ( mod n ) ,then a+ c ≡ b+c (mod n) and ac ≡bc (mod n)
f) If a ≡ b ( mod n ) , then a k ≡ bk (mod n) for any positive integer k .

 If ca ≡ cb( mod n), then a ≡ b(mod n / d), where d=gcd ( c , n ) .


 If ca ≡ cb( mod n) and gcd ( c , n )=1, then a ≡ b ( mod n ) .
 If ca ≡ cb( mod p) and p ∤c , where p is a prime number, then If a ≡ b ( mod p ) .
 CHINESE REMAINDER THEOREM*
Let m 1 ,m 2 , … ,m r be a collection of pairwise relatively prime integers. Then the system of simultaneous congruences,

x ≡ a1 ( mod m 1 )
x ≡ a2 ( mod m2 )

x ≡ ar (mod mr )

Has a unique solution modulo M =m 1 m2 … m r , and the solution is:

x=a 1 M 1 y 1 +a 2 M 2 y 2 +…+ ar M r y r
o eg. Find the solution to the linear congruence;
x ≡3 (mod 5)
{ x ≡ 4( mod 11)

Solution: Notice that we may write x in the form 5 k +3 and 11m+4.

x=5 k +3=11 m+4

7
Taking this equation mod 5 we arrive at 11 m+4 ≡ 3 ( mod 5 ) →m ≡−1 ( mod 5 ) . We substitute m=5 m 1−1 to
give usx=11 ( 5 m1−1 ) + 4=55 m1 −7.
Therefore x ≡ 48( mod 55) which means x=55 k + 48 for some integer k.

o The system of linear congruences

ax +by ≡r ( mod n )
cx +dy ≡ s(mod n)
Has a unique solution modulo n whenever gcd ( ad−bc ,n )=1

 FERMAT’S LITTLE THEOREM*


For any prime p and p ∤a any natural number a ,

a p−1 ≡1( mod p)

o If p is a prime, then a p ≡ a(mod p) for any integer a .


o Lemma: If p and q are distinct primes with a p ≡ a ( mod q ) and a q ≡ a ( mod p ) , then a pq ≡ a(mod pq)
o If n is and odd pseudoprime, then M n=2n −1 is a larger one.
o Let n be a composite square-free integer, say, n= p1 p2 … p r , where the pi are distinct primes. If pi −1∨n−1for
i=1 , 2, … , r , then n is an absolute pseudoprime.

 EULER’S TOTIENT THEOREM*


Let ϕ ( m ) denote the totient function. Then
a ϕ ( m) ≡ 1(mod m)

For all a relatively prime to m .


 CARMICHAEL’S LAMBDA FUNCTION “REDUCED TOTIENT FUNCTION”*
The Carmichael’s Lambda of a positive integer n , denoted by λ (n), is the smallest positive integer value of n that satisfies
a k ≡ 1(mod n)

For all positive integers a relatively prime to n . The value of λ (n) is given by the formula

ϕ ( pei ) if ei ≤ 2∨ pi ≥ 3

{
i

ei
λ(p i ) 1
ϕ ( p ei ) otherwise
i

λ ( n )=lcm ¿

 APPLICATION TO REMAINDER PROBLEMS USING TOTIENT/PHI FUNCTION, EULER’S TOTIENT THEOREM AND
CARMICHAEL’S LAMBDA*
-If we intend to find the remainder when a b is divided by n (where a , b , n are positive integers we can apply Euler’s Theorem if
a is relatively prime to n . To do so, we first evaluate ϕ ( n ) , then we find the remainder when b is divided by ϕ ( n ) . Denote the
remainder as c and the quotient as Q (there is no need to evaluate Q ). It follows that:
a b=a ϕ ( n) ⋅Q ⋅ ac
Q
¿ ( a ϕ ( n) ) ⋅ac
≡1Q ⋅a c ( mod n )
≡ ac (mod n)

Therefore, a b ≡ ac (mod n) which means that the remainder of the a b is the same as that of a c . Of course the latter should be
easier to evaluate since c <b . However, there are case when the value of c is still too large and the remainder is still quite hard to
evaluate. In that case, we can apply the lambda function. Following the same reasoning as the previous one, it must be true that

8
a b ≡ ad (mod n)

Where d is the remainder when b is divided by λ (n ).

*If a is not relatively prime to n , we have to factor either a or n , and then apply modular congruence properties or Chinese
Remainder Theorem where possible

 Eg. Find the remainder when 3 41is divided by 100


Solution:

Since 3 is relatively prime to 100, we can use the phi function. Note that 100=22 ⋅52 which implies that

ϕ ( 100 ) =100⋅ 1− ( 12 )(1− 15 )=40


Next, we find the remainder when 41 is divided by 40. Clearly, that remainder is 1. Hence, 3 41 ≡31 (mod 100). Therefore, the
remainder is 3.

 Eg. Find the remainder when 1 321 is divided by 100.


Solution:

We note that 13 is relatively prime to 100. We also note that ϕ ( 100 ) =40. Using Euler’s Theorem is not useful for this problem
because 21(mod 40) is still 21. Instead, we will use the lambda function.

We calculate the value of λ (100) as follows:

λ ( 22 ) =ϕ ( 22 )
1
( )
¿ 22 1−
2
¿2

λ ( 52 ) =ϕ ( 52 )
1
( )
¿ 52 1−
5
¿ 20

λ ( 100 ) =lcm ( λ ( 22 ) , λ ( 52 ) )
¿ lcm ( 2,20 )
¿ 20
2021.
23⋅ ⋅⋅
21
 Find the last two digits of 31 9
Solution:

The problem translates to finding the remainder when the given is divided by 100. Since 3 is relatively prime to 100. Euler’s
Theorem and Lambda function apply. From the first example, we know that ϕ ( 100 ) =40 ,and similar to the reasoning in
example 2. Euler’s Theorem does not provide immediate results. From the example 2, we know that λ ( 100 ) =20. Hence, we try
to find the remainder when the given exponent is divided by 20.
2021
2021
23 ⋅⋅ ⋅
2 1 23⋅⋅ ⋅ 21
19 ≡ (−1 ) ( mod 20 )
≡−1(mod 20)

Note that we have concluded that the expression is congruent to -1 because we are raising -1 to an odd power

9
The congruence relation then becomes:
2021
23 ⋅ ⋅⋅
21

31 9 ≡3−1( mod 100)

What’s left is to evaluate the 3−1 mod 100. Suppose this is equal to k.

3−1 ≡ k ( mod100 )
1 ≡3 k (mod 100)
2 ⋅ 100+1≡ 3 k ( mod 100 )
201 ≡3 k ( mod 100 )
201
≡k (mod 100)
3
67 ≡ k

Note that we’ve added 2 ⋅100 in the left-hand side of the congruence (in line 3) in order to yield an expression that is divisible by
3 (this allows us to solve for k . This is way of reasoning is generalized by Extended Euclidean Algorithm which is the most
common way to evaluate modular inverses.

Therefore, the remainder is 67.


2021
202
 eg. Find the remainder when 22 3 is divided by 27

Solution:

Since 2 is relatively prime to 27. Euler’s Theorem applied. We first evaluate ϕ ( 27 ) :

ϕ ( 27 )=27 1− ( 31 )=18
2021
Next, we find the remainder when the exponent 2 320 2 is divided by 18. However, this still hard to evaluate as is, but since 23 is
relatively prime to 18, we can use Euler’s Theorem again. Note that

ϕ ( 18 ) =18 1− ( 12 )(1− 13 )=6


Next, we find the remainder when 20 22021is divided by 6.

20 22021 ≡ 42021 ( mod 6)

Since 4 and 6 are relatively small numbers, it’s not hard to see pattern on remainder: the remainder when 4 n is divided by 6 for
all positive integers n . Hence, 20 22021 ≡ 4 ( mod 6 ) . It follows that

2021

2 320 2 ≡ 23 4 (mod 18)


The last expression can be evaluated by using modular arithmetic properties.

4 4
2 3 ≡ ( 5 ) ( mod18 )
≡ ( 25 )( 25 ) ( mod 18 )
≡ ( 7 )( 7 )( mod 18 )
≡ 49 ( mod 18 )
≡13 (mod 18)
Hence, the original congruence relation reduces to

10
2021
202

22 3 ≡ 213(mod 27)
Finally, we simplify the last expression using modular arithmetic properties.

213 ≡ ( 25 ) ( 25 )( 23 ) ( mod 27 )
≡ ( 32 ) ( 32 )( 8 )( mod 27 )
≡ ( 5 )( 5 ) ( 8 ) ( mod 27 )
≡ ( 25 )( 8 )( mod 27 )
≡ (−2 )( 8 )( mod 27 )
≡−16 ( mod 27 )
≡11 (mod 27)
Therefore, the remainder is 11

 WILSON’S THEOREM*
If p is a prime, then ( p−1 ) ! ≡−1(mod p)
o The quadratic congruence x 2+ 1≡ 0 ( mod p ) , where p is an odd prime, has a solution if and only if p ≡1 ( mod 4 ) .

 SUMS OF POWERS MODULO p


Let p be a prime and m an integer. Then
1m +2m +…+ ( p−1 )m ≡ 0 ( mod p ) if p−1 ∤m
{
−1 ( mod p ) if p−1∨m

 WOLSTENHOLME’S THEOREM. Let p>3 be a prime. Then ( p−1 ) ! ( 11 + 12 +…+ p−1


1
) ≡ 0( mod p ). 2

 HARMONIC MODULO p TRICK


For any integer k =1,2 , … , p−1, we have
1 1
≡ (−1 )k−1 ⋅ p ( mod p ) .
k p k ()
 LUCAS’ THEOREM - Lucas' theorem states that for non-negative integers m  and n , and a prime  p ,

() m ≡
n
∏ mn i ( mod p ) ,
()
i=0 i

Where m=mk pk +m k−1 p k−1 +…+ m1 p+m 0 and n=nk pk +nk −1 p k−1+ …+n1 p+n0 are the base pexpansions of m and n,
m =0
respectively. This uses the convention that
n ()
when m<n .

In particular,
(mn ) is divisible by p iff at least one of the base p digits of n is greater than the corresponding base pdigit of m .

Great for questions like:

 For which m and n  is 


(mn )even?

 What is the remainder when binomial coefficient like


(100
30 )
is divided by a prime number like 13?

 How many entries in the 34th row of Pascal’s triangle are divisible by 11? Which entries are not? What are they congruent to mod 11?

 ORDER AND PRIMITIVE ROOTS*


o DEFINITION (ORDER). The order of a mod m (with a and m relatively prime) is the smallest positive integer x such that
a ≡ 1(mod m) . We write this as x=¿ d m a or sometimes shorthanded to o m a .
x

11
 eg. The order of 2 mod 9 is 6 because
21 ≡ 2 ( mod 9 ) ,22 ≡ 4 ( mod 9 ) , 23 ≡ 8 ( mod 9 ) , 24 ≡7 ( mod 9 ) , 25 ≡5 ( mod 9 ) , 26 ≡ 1 ( mod 9 ) ,
 THEOREM 1. For relatively prime positive integers a and m , a n ≡1 ( mod m ) if and only if ¿ d m a∨n
 THEOREM 2. For relatively prime positive integers a and m

¿ d m a∨ϕ(m)

o DEFINTTION (PRIMITIVE ROOT). Let p be a prime. Then there exists an integer g , called a primitive root, such that the order of
g(mod p) equals p−1.
 eg. If p=13 , g=2 is a primitive root: 26 ≡64 ≡−1(mod p) but 212 ≡ 4096 ≡1(mod p)

 QUADRATIC RESIDUE AND LEGENDRE SYMBOL


o DEFINITION (QUADRATIC RESIDUE). A number a is a quadratic residue modulo p if there is some x such that
2
x ≡ a ( mod p ) .
o ie. If p=13 , then a=10 is a quadratic residue modulo p as 62 ≡36 ≡ 10 ( mod 13 ) .

o DEFINITION (LEGENDRE SYMBOL) For a relatively prime to p , we define the Legendre Symbol as follows:

1if ais a quadratic residue p


a
()
p {
= −1 if a is a quadratic nonresidue of p
0 if a ≡ 0 ( mod p )
 Let p be an odd prime and let a and b be integers that are relatively prime to p. Then the Legendre symbol has the following
properties:

a) If a ≡ b ( mod p ) , then
( ap )=( bp ).

a2
b)
( )
p
=1.
p −1
a
c)
()
p
≡a 2 .

ab a b
d)
( ) ( )( )
p
=
p p
.
p −1
1 −1
e)
() ( )
p
=1 and
p
= (−1 ) 2
 If p is an odd prime, then

( −1p )= {−11 ififpp≡1(mod 4)


≡3(mod 4)
 QUADRATIC RECIPROCITY For odd, distinct primes p and q .

p−1 q −1
p q ( )( )
( )( )
q p
= (−1 ) 2 2

p −1
 EULER’S CRITERION – Let p be an odd prime and gcd ( a , p ) =1. Then a is a quadratic residue of pif and only if a 2
≡1 ( mod p ) .
P-ADIC VALUATION

 DEFINITION: We define the p-adic valuation of m to be the highest power of p that divides m. The notation for this is vp ( m ) .
k k +1
v p ( n )=k ⟺ p ∨n , p ∤n

12
o eg. Since 20=22 ⋅ 5 we have v 2 ( 20 )=2 and v5 ( 20 )=1. Since 360=23 ⋅32 ⋅51 we have

v 2 ( 360 )=3 , v 3 ( 360 ) =2, v 5 ( 360 )=1. m can be a fraction, in this case we have v p ( ap )=v ( a )+ v ( b) .
p p (We can use this to

extend the definition of v p to be a function from Q≠ 0 → Z .

o Theorem 1. v p ( ab )=v p ( a )+ v p ( b ) . *why v p ( 0 )=∞ ?


o Theorem 2. If v p ( a ) > v p ( b ) thenv p ( a+b )=v p (b).
o Theorem 3. v p ( a+ b ) ≥min { v p ( a ) , v p ( b ) } , equality holds if v p ( a ) ≠ v p ( b ) .
o Theorem 4. v p ( a−b ) ≥ e ⟺ a ≡ b(mod pe ) from the previous.
o Theorem 5. v p ( gcd ( a , b ) )=min { v p ( a ) , v p ( b ) } .

o Theorem 6. v p ( lcm ( a , b ) ) =max { v p ( a ) , v p ( b ) } .


o Theorem 7. a=b ⟺ v p ( a ) =v p (b) for all p.
o Theorem 8. More generally, a∨b ⟺ v p ( a ) ≤ v p ( b ) for all p.

 P-ADIC VALUATION FOR FACTORIALS


o LEGENDRE’S THEOREM. For all positive integers n and positive primes p, we have


n
v p ( n ! )= ∑ ⌊ ⌋
i=1 pi
n
Where the series is infinite, because ⌊ ⌋ =0for pk >n .
pi

o LEGENDRE’S FORMULA:

∑ ⌊ nk ⌋
p
n !=∏ p k=1

p ≤n

o NUMBER OF TRAILING ZEROES – Let f (n) give the number of trailing zeros in the base ten representation of n !.
k
n n n n
f ( n )= ∑ ⌊ i
⌋=¿ ⌊ ⌋+ ⌊ 2 ⌋ +…+ ⌊ k ⌋ , ¿
i=1 5 5 5 5
Where k =⌊ log 5 n ⌋ .

o i.e. Determine the number of trailing zeros of 777 ! .

We plug in 777 to the formula and get

777 777 777 777


⌊ ⌋+ ⌊ ⌋+⌊ ⌋+⌊ ⌋=155+31+6+1=193.
5 25 125 625

777
*Note that the sequence stopped after ⌊ ⌋ because everything after would be 0. You do not have to memorize fancy
625
formula to do this kind of problem consistently, but just know how and why it works.
o LEGENDRE’S THEOREM IN NUMBER BASE.

Let p be a prime and let


n=a0 pk +a1 pk−1 +…+a k−1 p+a k
be the base− p expansion of n . The exact power m of a prime p dividing n ! is given by

13
n−( a0 +a1 +…+ ak )
v p ( n ! )=
p−1
the common proof of this theorem is with the help of Legendre’s formula:
m
n
v p ( n ! ) =∑ ⌊ ⌋
k=1 pk
Where m=⌊ log p n ⌋
This also equivalent to:
n−s p ( n )
v p ( n ! )=
p−1
Where s p (n) is the sum of the digits of n in base p and v p ( n ) give the highest power of p in n !.

 LIFTING THE EXPONENT (LTE)


o THEOREM 1. For p being an odd prime relatively prime to integers a and b with p | a−b then

v p ( an−b n )=v p ( a− p ) + v p ( n )
o COROLLARY 1. For p being an odd prime relatively prime to a and b with p∨a−b and n is an odd positive integer than

v p ( an +bn ) =v p ( a+b )+ v p (n)


o THEOREM 2. If p=2 and n is even, and
 4∨x − y then v 2 ( xn − y n )=v 2 ( x− y ) + v 2 (n)
 4∨x + y then v 2 ( x n− y n ) =v 2 ( x+ y )+ v 2 (n)

NUMBER-THEORETIC FUNCTION

 SUMMATION OF DIVISORS NOTATION

∑ f (d)
d ∨n

To mean, “Sum the values f (d ) as d runs over all the positive divisors of the positive integer n .” For instance, we have

∑ f ( d)=f ( 1 ) +f ( 2 ) + f ( 4 ) + f ( 5 )+ f ( 10 ) + f (20)
d ∨n

With this understanding, τ ∧σ may be expressed in the form:

N N
N N
τ ( n )=∑ 1=∑ ⌊ ⌋ σ ( n )=∑ d=∑ n ⌊ ⌋
d∨n n=1 n d∨n n=1 n

 PRODUCT NOTATION

∏ f ( d ) =f ( 1 ) f ( 2 ) f ( 3 ) f ( 4 ) f ( 5 )
1 ≤d ≤5

14
∏ f ( d )=f ( 1 ) f (3 ) f (9)
d ∨9

∏ f ( p )=f ( 2 ) f ( 3 ) f (5)
p ∨30
p prime

With this understanding, τ ∧σ may be expressed in the form:

pki +1−1
i

τ ( n )= ∏ ( k i +1 ) σ ( n ) = ∏
1 ≤i ≤r 1≤ i≤ r p i−1

 EULER’S PHI-FUNCTION – For n ≥ 1, let ϕ (n) denote the number of positive integers not exceeding n that are relatively prime to n .

1 1 1
ϕ ( n )=n 1− ( p1 )(
1−
p2
… 1− ) (
pk )
Where n is any positive integer and pn are prime divisors of n .
 If p is a prime and k > 0 , then

ϕ ( p k ) = pk − p k−1=p k 1− ( 1p )
 THE MÖBIUS INVERSION FORMULA – For a positive integer n , define μ by the rules

If n=1
1

{
μ ( n )= 0
(−1 )
r
If p2∨n for some prime p

 F ( n )= ∑ f ( d ) ⟹ f ( n ) =∑ μ
d ∨n d ∨n
( nd ) F ( d )=∑ μ ( d ) F ( nd )
d ∨n

 THE GREATEST INTEGER FUNCTION / FLOOR FUNCTION – ⌊ ∙ ⌋ : R → Z For an arbitrary real number x, we denote by ⌊ x ⌋ the
largest integer less than or equal to x; that is, ⌊ x ⌋ is the unique integer satisfying x−1< ⌊ x ⌋ ≤ x .

In general, ⌊ x ⌋ is the unique integer satisfying ⌊ x ⌋ ≤ x < ⌊ x ⌋ +1

Properties:
a) ⌊ x+ n ⌋ =⌊ x ⌋+ n for any integer n .
if x ∈ Z
⌊ x ⌋ + ⌊−x ⌋= −1
b)
0 {
c) ⌊ x+ y ⌋=⌊ x ⌋ + ⌊ y ⌋or ⌊ x ⌋ + ⌊ y ⌋ +1

 HERMITE’S IDENTITY – Let x be a real number, and let n be a positive integer. Then,

1 2 n−1
⌊ nx ⌋ =⌊ x ⌋+ ⌊ x + ⌋ + ⌊ x+ ⌋ + …+ ⌊ x + ⌋
n n n

15
Notice that there is no restriction on the sign of x , i.e. it can be positive or negative.

GENERAL LEGENDRE’S THEOREM – Let p be a prime and let


n=a0 pk +a1 pk−1 +…+a k−1 p+a k

be the base− p expansion of n . The exact power m of a prime p dividing n ! is given by

n−( a0 +a1 +…+ ak )


v p ( n ! )=
p−1

the common proof of this theorem is with the help of Legendre’s formula:

m
n
v p ( n ! ) =∑ ⌊ ⌋
k=1 pk
Where k =⌊ log p n ⌋

This also equivalent to:

( p−1 ) v p ( n ! ) =n−s p (n)

Where s p (n) is the sum of the digits of n in base p and v p ( n ) give the highest power of p in n !.

RIGHTMOST NON-ZERO DIGIT OF n !

Let
n
n ⌊ ⌋
D ( n ! )=⌊ ⌋ ! ×2 5 × ( n mod 5 ) !
5
n
 If ⌊ ⌋ ! Is sufficiently small, then the units digits D ( n ! ) gives us the value of the rightmost non-zero digit of n !.
5
n n

⌊ ⌋
( )
2 × ( n mod 5 ) !, which we call d 1. Now we solve for D ⌊ 5 ⌋ ! . Again, if we arrive at a
Otherwise, we find the units digit of 5

1 n n
( )
sufficiently small value of ⌊ ∙ ⌊ ⌋ ⌋ ! , then we evaluate the units digit of D ⌊ ⌋ ! (call this d ) and the final answer is d 1 ×d .
5 5 5

 If such a case doesn’t arise, then we keep on the iterating for

a
(⏞ 1 1 1 1 n
D ⌊ .... ⌊ ∙ ⌊ ∙ ⌊ ∙ ⌊ ⌋ ⌋ ⌋ ⌋ ... ⌋
5 5 5 5 5
! )
value of expression=m !
and record

the units digit of the product 2 × ( bi mod 5 ) ! (where a i and b i are to be followed from the original definition of D ( n ! ) and call them
i

{d 1 , d 2 , … , d k } . Once we arrive at a sufficiently small value for m! , we find the units digit of D ( m )(call this d ) and the final answer is
k

∏ d1× d .
i=1

(here sufficiently small value for m! refers to m∈ { 1,2,3,4 } .)

16
i.e. Find the rightmost non-zero digit of 501!

Using our method of continued iterations, we have

501
501 ⌊ ⌋
D ( 501! )=⌊ ⌋ ! ×2 5
× ( 501 mod 5 ) !=100! × 2100 ×1 !
5
100
100 ⌊ ⌋
D ( 100! )=⌊ ⌋!× 2 5
× ( 100 mod 5 ) !=20 ! × 220
5
20
20 ⌊ ⌋
D ( 20! )=⌊ ⌋ ! ×2 5 × ( 20 mod 5 ) !=4 ! ×24
5

Combining the
above three results, we have

D ( 501! )=( Units digit of 2100 ) × ( Unitsdigit of 220) × ( Unitsdigit of 4 ! ∙ 24 ) =( Unitsdigit of 6 × 6 × 4 )=4

 FACTORIALS- for all positive intgers, n ! (read as n factorial) is defined as:

n !=n ( n−1 ) !=n ( n−1 )( n−2 ) !=n ( n−1 ) ( n−2 ) … ( 2 ) (1 ) .

In words, n ! is the product of all positive integers less than or equal to n .

 DOUBLE FACTORIAL
o For an even number and n> 0 ,n ‼=n ( n−2 ) … ( 4 ) ( 2 ) .
o For an odd number and n> 0 ,n ‼=n ( n−2 ) … ( 3 ) ( 1 ) .
o If n=0 , 0 ‼=1

 For any non-negative integer n , we find that

n!
=( n−1 ) ‼∨n != ( n−1 ) ‼(n ‼)
n‼
 For any non-negative integer n , we find that

( 2n+ 1 ) !
= ( 2n+1 ) ‼
(2 n) !
 SUBFACTORIALS/DERANGEMENTS –
n
(−1 )k
! n=n ! ∑
k=0 k !

 BINOMIAL COEFFICIENT – If n and r are positive integers with 1 ≤r < n , then the binomial coefficient

n= n!
() r r ! ( n−r ) !
is also and integer.

 CEILING FUNCTION - (also known as the least integer function) ⌈ ∙⌉ : R → Z of a real number  x denoted  ⌈ x ⌉ , is defined as the smallest
integer that is not smaller than  x .

17
In general, ⌈x⌉ is the unique ineger satisfying  ⌈ x ⌉−1< x ≤ ⌈ x ⌉

Properties:
a) ⌈ x+ n⌉ =⌈ x ⌉ +n for any integer n .
⌈ x ⌉ + ⌈−x ⌉= 1 if x ∈ Z
b)
0 {
c) ⌈ x+ y ⌉=⌈ x ⌉ + ⌈ y ⌉ or ⌈ x ⌉ + ⌈ y ⌉ −1

 FRACTIONAL PART / SAWTOOTH FUNCTION – Let x be a real number. Then the fractional part of x is
{ x }=x−⌊ x ⌋
Properties:
a) 0 ≤ { x }<1 , and 0={x } if and only if x is an integer.
0 if x is an integer
b) { x } + {−x }=
{1
c) If a and b are integers and b> 0 , then
{ba }= br , where r is the remainder from dividing a and b .

 Other properties involving floor function and fractional part


a) ⌊ x ⌋ + { x }=x
b) ⌊ x+ y ⌋ ≥ ⌊ x ⌋ + ⌊ y ⌋
c) { x } + { y } ≥ {x + y }
d) ⌊ x+ n ⌋ =⌊ x ⌋+ n
e) { x +n }= { x }
f) ⌊ xy ⌋ ≥ ⌊ x ⌋ ⌊ y ⌋ for x , y ≥ 0
n
g) ⌊ √n x ⌋ ≤ ⌊ x ⌋
nx x
h) ⌊ ⌋ =n ⌊ ⌋
y y

BASE-B REPRESENTATIONS OF INTEGERS

 Any positive integer N can be written uniquely in terms of powers of b , b> 1, as

N=am bm + am−1 bm−1 +…+ a2 b 2+ a1 b+a0

Where the coefficients a k can take on the b different values 0, 1, 2,…,b−1.

*may be replaced by the simpler symbol

N= ( am a m−1 … a 2 a1 a0 ) b

6
i.e. 105=1∙ 2 +1∙ 25 +0 ∙2 4 +1∙ 23 +0 ∙ 22+0 ∙ 2+1=( 1101001 )2

 BINARY NUMBER – is a number expressed in the binary numeral system, which represents numbers using two digits: 0 and 1

 HEXADECIMAL NUMBER – (also known as base-16) are a system of numbers which have 16 digits, instead of 10.

These digits are:

18
0 , 1 ,2 , 3 , 4 , 5 , 6 ,7 ,8 ,9 , A , B , C , D , E , F ,

Where A is 10, B is 11, etc.

19

You might also like