Skip to main content

AMC 12 Mock Exam 10 Problem 19

Problem 19 of 25

For a positive integer nn, let f(n)f(n) be the exponent of the largest power of 33 that divides n!n!. For example, f(7)=2f(7)=2 because 7!=5040=32⋅5607!=5040=3^2\cdot560 and 560560 is not divisible by 33. For how many positive integers n<729n<729 is f(n)=n−42 ?f(n)=\frac{n-4}{2}\,?

Answer choices

Show solution

Solution

By Legendre's formula, f(n)=∑j≥1⌊n3j⌋f(n)=\sum_{j\ge1}\left\lfloor\frac{n}{3^j}\right\rfloor. Write nn in base 33 as n=∑idi3in=\sum_i d_i3^i with digits di∈{0,1,2}d_i\in\{0,1,2\}. Then ⌊n3j⌋=∑i≥jdi3i−j\left\lfloor\frac{n}{3^j}\right\rfloor=\sum_{i\ge j}d_i3^{i-j}, so f(n)=∑idi(3i−1+3i−2+⋯+1)=∑idi⋅3i−12=n−s(n)2,f(n)=\sum_i d_i\left(3^{i-1}+3^{i-2}+\cdots+1\right)=\sum_i d_i\cdot\frac{3^i-1}{2}=\frac{n-s(n)}{2}, where s(n)=∑idis(n)=\sum_i d_i is the base-33 digit sum. (Check: 7=2137=21_3, so f(7)=7−32=2f(7)=\frac{7-3}{2}=2.)

So the condition is exactly s(n)=4s(n)=4. Since n<729=36n<729=3^6, nn has at most six base-33 digits; write it with exactly six digits d0,…,d5d_0,\dots,d_5, allowing leading zeros. We count solutions of d0+⋯+d5=4d_0+\cdots+d_5=4 with 0≤di≤20\le d_i\le2. There are (95)=126\binom{9}{5}=126 solutions without the upper bound. Those with some di≥3d_i\ge3 have exactly one such digit, and it equals 33 or 44; there are 6⋅(65)=366\cdot\binom{6}{5}=36 of them. The count is 126−36=90126-36=\boxed{90}. Each solution gives a positive nn, since the digit sum is 44. (Forgetting the cap di≤2d_i\le2 gives 126126; using only five digits gives 4545.)

Tagged: Legendre's formula and base-3 digit sums