Let f(n) be the last non-zero digit in the decimal representation of n! . Show that for distinct integers ai ≥ 0, f(5a1 + 5a2 + ... + 5ar) depends only on a1 + ... + ar = a. Write the value as g(a). Find the smallest period for g, or show that it is not periodic.
Solution
Answer: period 4.
Let ν(n) denote the last non-zero digit of n. Evidently ν(10n) = ν(n) and if mn is not a multiple of 10, then ν(mn) = ν(ν(m)ν(n)) . We have ν((5n+1)(5n+2)) = ν((5n+3)(5n+4)) = 2. Hence f(5n) = ν(4n5nn!) = ν(2nn!) = ν(2n f(n)) (*).
We now show by induction that f(5a + 5b + ... ) = ν(2a+b + ...) for a > b > ... ≥ 0. It is clearly true for 5a + 5b + ... = 1 or 5. So suppose it is true for all values < N = 5a + 5b + ... There are two cases to consider. If the smallest power of 5 in N is 50, then N - 1 is a multiple of 5, so N ends in a 6 or a 1. (N - 1)! is even, so f(N-1) = 2, 4, 6 or 8. In any case its last digit is unchanged on multiplying by 1 or 6, so f(N) = f(N-1). The result is true for N - 1 and the a + b + ... is not changed by adding 0, so it is also true for N.
So it remains to consider the case where N is divisible by 5. In other words N = 5M, where M = 5a-1 + 5b-1 + ... . By (*), we have that f(N) =ν(2M f(M)). Now ν(25) = 2, so by a simple induction ν(2k) = 2 if k is any power of 5. Hence ν(2M) = ν(2n), where n is the number of terms in M = 2a-1 + 2b-1 + ... . By induction f(M) = ν(2a-1+b-1+ ...), hence f(N) = ν(2a+b+ ...) as required.
Finally, we find immediately that ν(21) = 2, ν(22) = 4, ν(23) = 8, ν(24) = 6, ν(25) = 2. Hence the period is 4.
© John Scholes
jscholes@kalva.demon.co.uk
7 Jan 2001