Let f(n) be the last non-zero digit in the decimal representation of n! . Show that for distinct integers a_{i} ≥ 0, f(5^{a1} + 5^{a2} + ... + 5^{ar}) depends only on a_{1} + ... + a_{r} = 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) = ν(4^{n}5^{n}n!) = ν(2^{n}n!) = ν(2^{n} f(n)) (*).

We now show by induction that f(5^{a} + 5^{b} + ... ) = ν(2^{a+b + ...}) for a > b > ... ≥ 0. It is clearly true for 5^{a} + 5^{b} + ... = 1 or 5. So suppose it is true for all values < N = 5^{a} + 5^{b} + ... There are two cases to consider. If the smallest power of 5 in N is 5^{0}, 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 = 5^{a-1} + 5^{b-1} + ... . By (*), we have that f(N) =ν(2^{M} f(M)). Now ν(2^{5}) = 2, so by a simple induction ν(2^{k}) = 2 if k is any power of 5. Hence ν(2^{M}) = ν(2^{n}), where n is the number of terms in M = 2^{a-1} + 2^{b-1} + ... . By induction f(M) = ν(2^{a-1+b-1+ ...}), hence f(N) = ν(2^{a+b+ ...}) as required.

Finally, we find immediately that ν(2^{1}) = 2, ν(2^{2}) = 4, ν(2^{3}) = 8, ν(2^{4}) = 6, ν(2^{5}) = 2. Hence the period is 4.

© John Scholes

jscholes@kalva.demon.co.uk

7 Jan 2001