Unless otherwise specified, all variables in these notes are integers.
The set of integers is denoted by Z={…,−2,−1,0,1,2,…}..
The set of positive integers, also known as the natural numbers, is denoted by N={1,2,3,…}..
Divisibility
Definition 1 (Divisibility).
We say ddividesn and write d∣n if n=dk for some k∈Z.. We also say d is a divisor of n,, or n is a multiple of d..
Symbolically,
d∣n⇔(∃k∈Z)(n=dk).
Basic Properties.
1∣n,,n∣n,, and n∣0 for every integer n..
(Proof: n=1×n,,n=n×1,, and 0=n×0.).)
(Transitivity) If a∣b and b∣c,, then a∣c..
(Proof: Write b=ak and c=bm.. Then c=a(km).).)
(Linearity) If d∣a and d∣b,, then d∣(ax+by) for all x,y∈Z..
(Proof: Write a=dk1 and b=dk2.. Then ax+by=d(k1x+k2y).).)
If a∣b and b=0,, then ∣a∣≤∣b∣..
(Proof: Write b=ak with k=0,, so ∣k∣≥1.. Then ∣b∣=∣a∣⋅∣k∣≥∣a∣.).)
If a∣b and b∣a,, then a=±b..
(Proof: If either is zero, both are zero. Otherwise, by (d), ∣a∣≤∣b∣ and ∣b∣≤∣a∣,, so ∣a∣=∣b∣.).)
Greatest Common Divisor
Definition 2 (GCD and LCM).
Suppose (a,b)=(0,0).. The greatest common divisor (GCD) of a and b is the largest integer g such that g∣a and g∣b.. Symbolically,
gcd(a,b)=max{g∈Z:g∣a and g∣b}.
By convention, we define gcd(0,0)=0 for a reason that will be clear soon. If gcd(a,b)=1,, we say that a and b are relatively prime (or coprime).
Suppose a and b are not both zero. The least common multiple (LCM) of a and b is the smallest positive integer m such that a∣m and b∣m.. Symbolically,
lcm(a,b)=min{m∈N:a∣m and b∣m}.
By convention, we define lcm(a,0)=lcm(0,a)=0 for all a∈Z..
Given a,b∈Z,, a linear combination of a and b is any integer of the form ax+by for some x,y∈Z.. The set of all linear combinations of a and b is
aZ+bZ={ax+by:x,y∈Z}.
Exercise 3.
Prove that 6Z+10Z=2Z.. In other words, the set of all linear combinations of 6 and 10 is precisely the set of all multiples of 2..
Hint: Show two inclusions separately. For 6Z+10Z⊆2Z,, note that 6x+10y=2(3x+5y) is always even. For 2Z⊆6Z+10Z,, find specific integers x and y such that 6x+10y=2;; then every multiple of 2 is a multiple of this linear combination.
Recall that we defined gcd(0,0)=0.. The following proposition holds true even in the special case a=b=0..
Proposition 4.
For any a,b∈Z,,
aZ+bZ=gZ,
where g=gcd(a,b)..
Corollary 5.
If d∣a and d∣b,, then d∣gcd(a,b)..
Proof.
Let g=gcd(a,b).. By linearity, d divides every element of aZ+bZ=gZ.. In particular, d∣g..
An important application of Proposition 4: the equation ax+by=c has integer solutions if and only if gcd(a,b)∣c,, because the left-hand side ranges over all elements of aZ+bZ=gcd(a,b)Z..
Exercise 6.
Which of the following equations have integer solutions in x and y??
6x+10y=2
17x−43y=1
9x+30y=45
Answers
gcd(6,10)=2 and 2∣2..Yes. (For instance, x=2,,y=−1.).)
gcd(17,43)=1 and 1∣1..Yes. (For instance, x=−5,,y=−2.).)
gcd(9,30)=3 and 3∣45..Yes. (For instance, x=5,,y=0.).)
Remark. What if part (c) asked for 9x+30y=44 instead? Since gcd(9,30)=3 and 3∤44,, there would be no integer solutions.
Once we know that ax+by=n has one integer solution, the next proposition describes all of them.
Proposition 7.
Let a,b,n∈Z with (a,b)=(0,0).. Suppose (x0,y0) is an integer solution to the equation
ax+by=n.
Then the general integer solution is given by
⎩⎨⎧xy=x0+gbk=y0−gak
where k∈Z and g=gcd(a,b)..
Proof.
Write a′=a/g and b′=b/g.. Every pair in the family is a solution, because
a(x0+b′k)+b(y0−a′k)=n+gabk−gabk=n.
Conversely, let (x,y) be any solution. If b=0,, then a=0 and g=∣a∣,, so the equation forces x=x0 while y is arbitrary; this is exactly the family above, since a′=±1.. So assume b=0.. Subtracting ax0+by0=n from ax+by=n and dividing by g gives
a′(x−x0)=b′(y0−y).
By Proposition 4, g=au+bv for some integers u,v;; dividing by g shows 1 is a linear combination of a′ and b′,, so gcd(a′,b′)=1.. Since b′∣a′(x−x0),, Euclid’s Lemma (Proposition 17 below) gives b′∣(x−x0).. Write x−x0=b′k.. Substituting back, a′b′k=b′(y0−y),, and cancelling b′=0 gives y=y0−a′k..
Corollary 8.
Let a,b∈N.. The number of lattice points on the line segment connecting (0,0) and (a,b),, including both endpoints, is gcd(a,b)+1..
Proof.
Write g=gcd(a,b).. The equation of the line joining (0,0) and (a,b) is bx−ay=0.. By Proposition 7 with the solution (x0,y0)=(0,0),, and replacing k by −k,, the general integer solution is
⎩⎨⎧xy=gak=gbk
where k∈Z.. The lattice points on the line segment are given by k=0,1,…,g..
Example 9.
One solution of 2x+3y=1 is (x0,y0)=(2,−1).. Since gcd(2,3)=1,,Proposition 7 gives the general integer solution
{xy=2+3k=−1−2k
where k∈Z.. Geometrically, the integer solutions are the lattice points on the line 2x+3y=1,, and consecutive ones differ by the vector (3,−2).. The same spacing holds for every line 2x+3y=n..
Lattice points on 2x+3y=1 (lower line) and 2x+3y=12 (upper line).
Proposition 10 (Chicken McNugget Theorem).
Let a,b∈N with gcd(a,b)=1.. Consider the set
S={ax+by:x,y∈Z and x,y≥0}.
The largest integer which is not in S is ab−a−b..
This result is also known as the Frobenius coin problem for two coins, or Sylvester’s theorem.
Proof.
First, ab−a−b∈/S.. Suppose instead ax+by=ab−a−b with x,y≥0.. Then a(x+1)+b(y+1)=ab,, so a∣b(y+1),, and Euclid’s Lemma gives a∣(y+1).. Since y+1>0,, we get y+1≥a.. Similarly x+1≥b.. But then a(x+1)+b(y+1)≥2ab>ab,, a contradiction.
Next, every integer n>ab−a−b is in S.. Since gcd(a,b)=1,, the equation ax+by=n has integer solutions, and by Proposition 7 the values of y run through y0−ak for all k∈Z.. Choose k so that 0≤y≤a−1.. Then
ax=n−by≥n−b(a−1)>(ab−a−b)−ab+b=−a,
so x>−1,, that is, x≥0.. Hence n∈S..
Euclidean Algorithm
Although gcd(a,b) can be read off easily from the prime factorizations of a and b,, finding those factorizations in the first place is typically far more expensive than computing the GCD directly. The Euclidean algorithm provides a very efficient method for finding gcd(a,b).. For simplicity, we focus on the case of two distinct positive integers.
Algorithm 11 (Euclidean Algorithm).
Given positive integers a>b>0,, define r0=a,,r1=b,, and for k≥2,, define the quotient qk−1 and remainder rk by
rk−2=qk−1rk−1+rk,0≤rk<rk−1.
The positive remainders form a strictly decreasing sequence r0>r1>⋯>rn>0.. The process terminates when rn+1=0 for some n.. The last nonzero remainder rn is gcd(a,b)..
Proof sketch.
At each step, rk−2=qk−1rk−1+rk shows that any common divisor of rk−1 and rk also divides rk−2 (by linearity), and any common divisor of rk−2 and rk−1 also divides rk=rk−2−qk−1rk−1 (again by linearity). Therefore gcd(rk−2,rk−1)=gcd(rk−1,rk) at every step. Chaining these equalities gives
gcd(a,b)=gcd(r0,r1)=⋯=gcd(rn,0)=rn.
Example 12.
We find gcd(510,374) using the Euclidean algorithm.
k
rk
qk
0
510
1
374
1
2
136
2
3
102
1
4
34
3
5
0
The last nonzero remainder is r4=34.. Therefore, gcd(510,374)=34..
The Euclidean algorithm can be extended to find integers x and y such that ax+by=gcd(a,b)..
Algorithm 13 (Extended Euclidean Algorithm).
Using the notation of Algorithm 11, define two additional sequences with initial conditions x0=1,,y0=0,,x1=0,,y1=1,, and for k≥2,,
xk=xk−2−qk−1xk−1,yk=yk−2−qk−1yk−1.
All three sequences rk,,xk,,yk satisfy the same recurrence zk=zk−2−qk−1zk−1,, but with different initial conditions. This common structure ensures that the relation
axk+byk=rk
holds for every k,, which can be verified by induction. In particular, at termination where rn=gcd(a,b),, we obtain axn+byn=gcd(a,b)..
Example 14.
We extend the previous computation to find integers x and y such that 510x+374y=34..
k
rk
qk
xk
yk
0
510
1
0
1
374
1
0
1
2
136
2
1
−1
3
102
1
−2
3
4
34
3
3
−4
5
0
The equation 510x+374y=34 has a solution (x,y)=(3,−4)..
Exercise 15.
Use the Extended Euclidean Algorithm to find a solution to 17x−43y=1 from Exercise 6(b).
Hint: Rewrite the equation as 43(−y)+17x=1 and apply the algorithm with a=43 and b=17..
Hint: If dividing A by N leaves a remainder of r,, then N∣(A−r).. Apply this to both conditions. By linearity, N divides every linear combination of the two differences, so N divides their GCD g,, which the Euclidean algorithm finds quickly. Then N must be one of the divisors of g,, and it must be larger than the remainders. Which divisor of g satisfies this?
Euclid’s Lemma and Prime Numbers
Proposition 17 (Euclid's Lemma).
If a∣bc and gcd(a,b)=1,, then a∣c..
Proof.
Since gcd(a,b)=1,,Proposition 4 guarantees integers x,y∈Z such that
ax+by=1.
Multiplying both sides by c::
acx+bcy=c.
Now a∣ac (trivially) and a∣bc (by hypothesis). By linearity, a∣(acx+bcy)=c..
Definition 18 (Prime and Composite Numbers).
An integer p>1 is a prime number if its only positive divisors are 1 and p itself. An integer n>1 is a composite number if it is not prime, i.e., n=ab for some integers 1<a,b<n..
Remark. The integer 1 is neither prime nor composite. In the terminology of ring theory, 1 is a unit element (it has a multiplicative inverse in Z).).
Recall that a and b are relatively prime when gcd(a,b)=1.. This is equivalent to saying that a and b share no common prime divisor.
Exercise 19.
Are the following numbers prime or composite?
299−1
Hint: Note that 99=9×11 is not prime. Use the factorization xk−1=(x−1)(xk−1+xk−2+⋯+1) with x=29 and k=11..
299+1
Hint: Note that 99 is odd. When k is odd, xk+1=(x+1)(xk−1−xk−2+⋯−x+1).. Apply this with x=2 and k=99..
974+4
Hint: Use the Sophie Germain identity: a4+4b4=(a2+2b2+2ab)(a2+2b2−2ab).. Set a=97 and b=1..
Exercise 20.
Suppose n is a positive integer.
Prove that if 2n−1 is prime, then n must be a prime.
Hint: If n=ab with a,b>1,, then 2n−1=(2a)b−1.. Use the factorization xb−1=(x−1)(xb−1+⋯+1) with x=2a to find a nontrivial divisor.
Prove that if 2n+1 is prime, then n must be a power of 2..
Hint: If n has an odd factor k>1,, write n=km.. Then 2n+1=(2m)k+1.. Use the factorization xk+1=(x+1)(xk−1−xk−2+⋯+1) with x=2m to find a nontrivial divisor.
Proposition 21.
If p is a prime number, then for any a∈Z,, either p∣a or gcd(a,p)=1..
Proof.
Let g=gcd(a,p).. Since g is a positive divisor of p and p is prime, we have g=1 or g=p.. If g=p,, then p∣a.. Otherwise g=1,, meaning gcd(a,p)=1..
Proposition 22.
If p is a prime number and p∣ab,, then p∣a or p∣b..
Proof.
Suppose p∤a.. By Proposition 21, gcd(a,p)=1.. Since p∣ab,, Euclid’s Lemma gives p∣b..
Proposition 23.
If a∣n,,b∣n,, and gcd(a,b)=1,, then ab∣n..
Proof.
Since a∣n,, write n=ak.. Then b∣ak and gcd(a,b)=1,, so Euclid’s Lemma gives b∣k.. Write k=bm.. Then n=ak=a(bm)=(ab)m,, hence ab∣n..
Example 24.
Since gcd(3,5)=1,, the preceding proposition tells us: if 3∣n and 5∣n,, then 15∣n..
The coprimality condition gcd(a,b)=1 is essential. For instance, 4∣12 and 6∣12,, but 24∤12.. Here gcd(4,6)=2=1,, so the proposition does not apply.
Among any three consecutive integers, one is even and one is a multiple of 3,, so their product is always divisible by 6.. Since 7∣n and gcd(6,7)=1,,Proposition 23 gives 42∣n.. Therefore n is necessarily divisible by every divisor of 42:: namely 1,2,3,6,7,14,21,, and 42.. This eliminates (A), (B), (C), and (E).
The answer is (D). To confirm, take n=5×6×7=210:: we have 7∣210 but 28∤210..
Example 26.
Find the smallest positive integer n such that 7∣(n+2) and 11∣(n+2)..
Solution
Since gcd(7,11)=1 and both 7 and 11 divide n+2,,Proposition 23 gives 77∣(n+2).. The smallest positive n satisfies n+2=77,, giving n=75..
Proposition 27 (Fundamental Theorem of Arithmetic).
Every integer n≥2 can be written as a product of primes
n=p1p2⋯pk,
and this representation is unique up to the order of the factors.
Proof sketch.
Existence. By strong induction. If n is prime, we are done. If n is composite, write n=ab with 1<a,b<n.. By the inductive hypothesis, both a and b are products of primes, so n=ab is as well.
Uniqueness. Suppose n=p1p2⋯pk=q1q2⋯qm are two prime factorizations. Since p1∣q1q2⋯qm,, repeated application of Proposition 22 gives p1∣qj for some j.. Since both are prime, p1=qj.. Cancel this common factor and repeat; the two factorizations must agree up to reordering.
The 𝑝-adic Valuation
Definition 28 (𝑝-adic Valuation).
Let p be a prime number and let n=0 be an integer. The p-adic valuation of n is
νp(n)=max{e≥0:pe∣n}.
If p∤n,, then νp(n)=0.. If p∣n but p2∤n,, then νp(n)=1.. In general, νp(n) is the exponent of p in the prime factorization of ∣n∣..
n
ν2(n)
ν3(n)
ν5(n)
10
1
0
1
12
2
1
0
180
2
2
1
As a concrete illustration, suppose a=p3q and b=p3q2r,, where p,,q,,r are distinct primes. To check whether a∣b,, compute the quotient:
ab=p3qp3q2r=p3−3q2−1r1−0=qr.
Since the quotient is a positive integer, we conclude a∣b..
Proposition 29.
For any nonzero integers a and b and any prime p,,
νp(ab)=νp(a)+νp(b).
Proposition 30.
For nonzero integers a and b,,
a∣b⇔νp(a)≤νp(b) for every prime p.
Corollary 31.
For any nonzero integers a and b and any prime p,,
We use the fact that lcm(a,b) takes the maximum of each prime’s valuation while gcd(a,b) takes the minimum (Corollary 31). The relevant factorizations are 18=2⋅32,,180=22⋅32⋅5,,45=32⋅5,, and 15=3⋅5..
From lcm(n,18)=180::
max(ν2(n),1)=2,, so ν2(n)=2..
max(ν3(n),2)=2,, so ν3(n)≤2..
max(ν5(n),0)=1,, so ν5(n)=1..
From gcd(n,45)=15::
min(ν3(n),2)=1,, so ν3(n)=1..
min(ν5(n),1)=1,, consistent with ν5(n)=1..
Therefore n=22⋅3⋅5=60,, and the sum of its digits is 6+0=6.. The answer is (B).
(B) 14. A number is divisible by 5 if and only if its last digit is 0 or 5.. The last digit of the reversed number equals the hundreds digit of N.. Since N is a three-digit number, its hundreds digit cannot be 0,, so it must be 5.. Thus N∈{500,501,…,599} and 7∣N.. The multiples of 7 in this range run from 504=7×72 to 595=7×85,, giving 85−72+1=14..
Problem 2
(C) 37. Since 2019=3×673 (both prime), we have 20199=39⋅6739.. A divisor 3a⋅673b (with 0≤a,b≤9)) is a perfect square when both exponents are even: 5×5=25 choices. It is a perfect cube when both are divisible by 3::4×4=16 choices. It is a perfect sixth power when both are divisible by 6::2×2=4 choices. By inclusion–exclusion, the count is 25+16−4=37..
Problem 3
(C) 2. Write n=7k⋅m where 7∤m.. The divisor count gives (k+1)⋅d(m)=60 and (k+2)⋅d(m)=80.. Dividing: k+1k+2=6080=34,, so 3k+6=4k+4,, hence k=2..
Problem 4
(E) 23. We have 12!=210⋅35⋅52⋅7⋅11,, giving (11)(6)(3)(2)(2)=792 total divisors. For a perfect square divisor, each prime’s exponent must be even: 6 choices for the exponent of 2 (from {0,2,4,6,8,10}),),3 for 3 (from {0,2,4}),),2 for 5 (from {0,2}),), and 1 each for 7 and 11 (only {0}).). This gives 6⋅3⋅2⋅1⋅1=36 perfect square divisors. The probability is 79236=221,, so m+n=1+22=23..