Exercise 1333Number theory › Divisibility and gcdOlympiadAdded 5 Nov 2026
v_p(n!) from the digits of n in base p
#Legendre's formula#digit sum#p-adic valuation#base p
Statement
Let be a prime and the sum of the digits of in base .
- Prove that .
- Deduce that iff is a power of , and that .
Hint
Write . What is in terms of the digits?
Show solutionHide solution
Solution
1. Write with . Then . By Legendre's formula,
Since the term contributes , the sum equals .
2. For : . Since , , with equality iff , i.e. is a power of . So iff is a power of .
Next, , so
Check. and ✓. , , ✓.
Lesson. Legendre's formula is just a statement about the digits of in base ; switching to digits often turns a messy floor sum into a clean closed form.