p Adic Valuation
p Adic Valuation
Leo.Euler
July 2022
Contents
1 Introduction 2
2 Legendre’s Theorem 2
3 Kummer’s Theorem 3
5 Problems 6
1
1 Introduction
We define the p-adic valuation of n as follows:
n
Definition 1.1. For any positive integer n and prime p, νp (n) is the largest integer k for which pk
is an
integer not divisible by p.
The following properties about νp hold.
• νp (gcd(a, b)) = min(νp (a), νp (b)). Similarly, νp (lcm(a, b)) = max(νp (a), νp (b)).
• νp (a + b) ≥ min(νp (a), νp (b)). Furthermore, if νp (x) ̸= νp (y), then νp (x + y) =
min(νp (x), νp (y)).
The proof of the above theorem is left as an exercise for the reader (hint: use properties of prime factor-
ization).
is not integral.
Pn 1
Solution. The idea here is to show that ν2 i=1 i < 0. Applying the fourth property in Theorem 1.1
iteratively, we obtain
Xn
1 1
ν2 = min1≤i≤n ν2 = −⌊log2 (n)⌋.
i=1
i i
Pn 1
Since −⌊log2 (n)⌋) < 0, i=1 i is not integral, as desired.
□
2 Legendre’s Theorem
Theorem 2.1 (Legendre’s Theorem) For any positive integer n and prime p, we have
∞
X n
νp (n!) = .
pk
k=1
n n νX
p (i) νp (i) n ∞ ∞
X X XX X X X n
νp (n!) = νp (i) = 1= 1= 1= .
i=1 i=1 k=1
pk
k=1 i=1 k=1 pk |i,1≤i≤n k=1
2
The following theorem is an alternative form of Theorem 2.1 while also a corollary.
Corollary 2.1 For any positive integer n and prime p, let sp (n) be the sum of the digits of n when
written in base p. Then,
n − sp (n)
νp (n!) = .
p−1
Proof. Suppose that the base p representation of n is (ak ak−1 . . . a0 )p . Then, we have
k k k X k k X k k
pj − 1
X n X X X X
νp (n!) = = (ak pk−i + . . . + ai ) = aj pj−i = aj pj−i = aj .
i=1
pi i=1 i=1 j=i j=i i=1 j=0
p−1
(b) By (a) we must find the expected value of s2 (n). We can think of the binary representation of n as
2021 slots, in which each slot is filled with either a 0 or a 1. By Linearity of Expectation, the desired
2021
expectation is 2021(0 · 1/2 + 1 · 1/2) = . □
2
Example 2.2 (Canada): Find all positive integers n such that 2n−1 divides n!.
3 Kummer’s Theorem
2n
We saw in Example 2.1 how to use the alternate form of Legendre’s Theorem to find ν2 of n . Kum-
mer’s Theorem generalizes this result.
Theorem 3.1 (Kummer’s Theorem) Let m and n be positive integers with m > n. If k is the
number of carries made when n is added to m − n in base p, then
m
νp = k.
n
3
Proof. By Theorem 1.1 and Corollary 2.1,
m m − sp (m) − ((n − sp (n)) + (m − n − sp (m − n)) sp (n) + sp (m − n) − sp (m)
νp = = .
n p−1 p−1
sp (n)+sp (m−n)−sp (m)
Showing that k is indeed equal to p−1 is left as an exercise for the reader.
Theorem 4.1 (LTE) Let a and b be integers and p be an odd prime with p ∤ a, b and p | (a − b).
Then, for all positive integers n
νp (an − bn ) = νp (a − b) + νp (n).
When p = 2,
ν2 (an − bn ) = ν2 (a2 − b2 ) + ν2 (n) − 1.
Proof. Let p be an odd prime. We first state and prove two lemmas and then use them to prove the final
theorem.
Lemma 1. If p ∤ n, then νp (an − bn ) = νp (a − b).
Proof of Lemma 1. We can write
n−1
X
νp (an − bn ) = νp (a − b) + νp an−1−i bi .
i=0
Pp−1
Considering i=0 ap−1−i bi modulo p, we have
n−1
X n−1
X
an−1−i bi ≡ an−1 ≡ nan−1 ̸≡ 0 (mod p).
i=0 i=0
Pp−1
Suppose that b = a + pk. Considering i=0 ap−1−i bi modulo p2 , we have
p−1
X p−1
X
p−1−i i
a b = ap−1−i (a + pk)i
i=0 i=0
p−1
X i i i
≡ ap−1−i pai−1 k+ a
i=0
1 0
p−1
X
≡ (iap−2 pk + ap−1 )
i=0
p−2 2
≡ a p (p − 1)/2 + p
≡ p (mod p2 ).
Thus, νp (ap − bp ) = νp (a − b) + 1.
4
Let n = pj · m, where p ∤ m. Then,
j j
νp (an − bn ) = νp ((ap )m − (bp )m )
j j
= νp (ap − bp ) (by Lemma 1)
j−1 j−1
= νp ((ap )p − (bp )p )
j−1 j−1
= νp ((ap ) − (bp )) + 1 (by Lemma 2).
Repeating the last two steps iteratively gives us that νp (an − bn ) = νp (a − b) + νp (n), as desired.
Example 4.1 (USA TST 2008): Prove that n7 + 7 is not a perfect square for any integer n.
Solution. One computational observation that we can make is the fact that 112 + 7 = 27 . This motivates
us to use LTE.
Assume to the contrary that n7 + 7 = x2 for some integer n and positive integer x. It can be easily seen
that n > 0. We do a quick (mod 4) check on both sides of the equation to find that n ≡ 1 (mod 4).
Adding 112 to both sides of our original equation, we obtain
n7 + 27 = x2 + 112 .
Since n + 2 > 0 and (n + 2) | (x2 + 112 ), x2 + 112 has a divisor that is 3 (mod 4). If x and 11 are relatively
prime, then by Fermat’s Two Square Theorem all of the divisors of x2 + 112 are 1 (mod 4), which is
clearly not the case, so (x, 11) ̸= 1. Thus, 11 | x.
Claim – ν11 (n + 2) = 1.
Proof of Claim. Let x = 11x0 . Then, x2 + 112 = 112 (x20 + 1). By Fermat’s Two Square Theorem on x20 + 1,
all divisors of x20 + 1 are 1 (mod 4). Thus, all prime divisors of n + 2 that are not 11 are 1 (mod 4). Since
n + 2 ≡ 3 (mod 4), 11 | (n + 2). Next, we will show that 112 ∤ n + 2. Assume to the contrary that
112 | n + 2. Then, since (n + 2) | 112 (x20 + 1) we have (n + 2)/112 | x20 + 1. However, since (n + 2)/112 ≡ 3
(mod 4), we have a contradiction. Thus, ν11 (n + 2) = 1. □
By LTE,
ν11 (x2 + 112 ) = ν11 (n7 + 27 ) = ν11 (n + 2) + ν11 (7) = 1 + 0 = 1.
However, we already showed that ν11 (x2 + 112 ) ≥ 2, a contradiction. Therefore, n7 + 7 is not a perfect
square for any integer n. □
Example 4.2 (2018 AIME I): Find the least positive integer n such that when 3n is written in base
143, its two right-most digits in base 143 are 01.
Solution. The statement is equivalent to asking for the least positive integer n such that 1432 | (3n − 1).
This further simplifies to 112 | (3n − 1) and 132 | (3n − 1). Since 5 is the smallest k for which 3k ≡ 1
(mod 11), and 3 is the smallest k for which 3k ≡ 1 (mod 13), 3 | n and 5 | n by the Fundamental Theorem
of Orders. By LTE,
( ( (
ν11 (243n/5 − 1) ≥ 2 ν11 (243 − 1) + ν11 (n/5) ≥ 2 ν11 (n/5) ≥ 0
⇔ ⇔
ν13 (27n/3 − 1) ≥ 2 ν13 (27 − 1) + ν13 (n/3) ≥ 2 ν13 (n/3) ≥ 1.
Thus, the set of all n satisfying 1432 | (3n − 1) is the same as the set of all n satisfying 3 | n, 5 | n, and
13 | n, so the minimum possible value of n is 3 · 5 · 13 = 195 . □
5
5 Problems
Problem 1. Prove Theorem 1.1.
Problem 2. Prove the p = 2 case of Theorem 4.1.
Problem 3 (2003 Putnam). Show that for each positive integer n,
n
Y n
n! = lcm 1, 2, . . . , .
i=1
i
Problem
√ 4 (BAMO 2018). Let a, b, c be positive integers. Show that if a/b + b/c + c/a is an integer, then
3
abc is an integer as well.
Problem 5 (2020 AIME I). Let n be the least positive integer for which 149n − 2n is divisible by 33 · 55 · 77 .
Find the number of positive integer divisors of n.
Problem 6 (IMO 2015). Determine all triples of positive integers (a, b, c) such that each of the numbers
ab − c, bc − a, ca − b
is a power of 2.
Problem 7 (2016 USAMO). Prove that for any positive integer k,
k−1Y j!
k2 ! ·
j=0
(j + k)!
is an integer.
Problem 8 (USEMO 2020). Which positive integers can be written in the form
lcm(x, y) + lcm(y, z)
lcm(x, z)
2n + 1
n2
is an integer.