For each positive integer k, we let F(k) denote the number of positive integers less than or equal to 2007 which are divisible by k. Clearly, F(k)=⌊k2007⌋, the integer part of the rational number k2007.
Because 55>2007, the exponent of 5 in the decimal expansion of 2007! is equal to
F(5)+F(52)+F(53)+F(54).
An easy calculation gives F(5)=401, F(25)=80, F(125)=16 and F(625)=3, hence the exponent of 5 in the decimal expansion of 2007! is equal to 500.
On the other hand, there are 1003 even numbers among the positive integers less than 2007 which implies that the exponent of 2 in the decimal expansion of 2007! is at least 1003. This proves that 10500 divides 2007!, but 10501 does not divide 2007!. The decimal expansion of 2007! ends in 500 zeros.
The idea for the calculation of the digit directly in front of these 500 zeros is the following. We calculate modulo 10 the product of all odd factors in the product 2007!, discarding those which are divisible by 5. The product of all even factors is equal to 1003!×21003 and we calculate modulo 10 the product of all those factors in 1003! which are co-prime to 5. From the factors not considered so far, we split off the factor 5 and proceed as before. After repeating this procedure a few times we obtain 2007!=n×21003×5500. The calculation gives the value of n modulo 10.
The calculations modulo 10 simplify if we take into account that for each integer k we have
(10k+1)(10k+3)(10k+7)(10k+9)≡−1mod10(1)
and
i=1i=5∏9(10k+i)≡−6mod10.(2)
Moreover, (−6)m≡(−1)m6mod10.
The product of all odd numbers 1,3,...,1999, co-prime to 5, consists of 200 products as in (1), so this contributes (−1)200≡1mod10. We also have 2001×2003×2007≡1mod10. As seen above, there are F(5)=401 positive integers below 2007 which are divisible by 5. Exactly 201 of them are odd. Hence, the product of all positive odd numbers below 2007 is equal to
M1×5201×401!!,
where M1≡1mod10 and 401!! denotes the product of all positive odd integers less or equal to 401.
Similarly, 401!!=M2×540×79!! with M2≡(−1)40≡1mod10. In the next step we get 79!!=M3×58×15!! with M3≡(−1)8≡1mod10. Finally,
15!!=1×3×5×7×9×11×13×15=M4×52
with M4≡1mod10. Altogether we obtained so far
2007!!=M×5251
with M≡M1M2M3M4≡1mod10.
To deal with the product of all even factors in 2007!, which is equal to 1003!×21003, we study 1003!. This product contains 100 products as in (2), which contributes (−1)1006≡6mod10. In addition, we have to consider 1001×1002×1003≡6mod10. The number of factors in 1003! which are divisible by 5 is equal to 200 so that
1003!=N1×5200×200!
with N1≡6(mod10).
Similarly, 200!=N2×540×40! with N2≡(−1)206≡6(mod10). Next, we obtain 40!=N3×58×8! with N3≡(−1)46≡6(mod10). Finally, 8!=N4×5 with N4=2×3×4×(−4)×(−3)×(−2)≡−6(mod10). Therefore,
1003!=N×5249
with N≡N1N2N3N4≡−6(mod10). We obtain
2007!=M×N×5500×21003=M×N×2503×10500
and we know M×N≡−6≡4(mod10). It remains to find 2503≡8(mod10), which is easily seen from 24≡6(mod10). We conclude that
M ×N×2503≡4×8≡2(mod10).
Therefore, the last non-zero digit of 2007! is equal to 2.