Olympiad Maths Prep

Track / Stage 6 / 174 of 400 #1174 of 2000

Problem 1174

National olympiad, first round
Number theory Difficulty 6.3 Find the answer

Find the number of zeros in which the decimal expansion of 2007! 2007! ends. Also find its last non-zero digit.

Official solution

1. **Finding the number of trailing zeros in 2007!2007!:**

The number of trailing zeros in 2007!2007! is determined by the number of times 1010 is a factor in 2007!2007!. Since 10=2×510 = 2 \times 5, and there are always more factors of 22 than 55 in factorials, we only need to count the number of factors of 55.

The number of factors of 55 in 2007!2007! can be found using the formula:
20075+200725+2007125+2007625 \left\lfloor \frac{2007}{5} \right\rfloor + \left\lfloor \frac{2007}{25} \right\rfloor + \left\lfloor \frac{2007}{125} \right\rfloor + \left\lfloor \frac{2007}{625} \right\rfloor

Calculating each term:
20075=401.4=401 \left\lfloor \frac{2007}{5} \right\rfloor = \left\lfloor 401.4 \right\rfloor = 401
200725=80.28=80 \left\lfloor \frac{2007}{25} \right\rfloor = \left\lfloor 80.28 \right\rfloor = 80
2007125=16.056=16 \left\lfloor \frac{2007}{125} \right\rfloor = \left\lfloor 16.056 \right\rfloor = 16
2007625=3.2112=3 \left\lfloor \frac{2007}{625} \right\rfloor = \left\lfloor 3.2112 \right\rfloor = 3

Summing these values:
401+80+16+3=500 401 + 80 + 16 + 3 = 500

Therefore, the number of trailing zeros in 2007!2007! is 500500.

2. **Finding the last non-zero digit of 2007!2007!:**

To find the last non-zero digit of 2007!2007!, we need to consider the factorial modulo 1010 while ignoring the factors of 1010 (i.e., factors of 22 and 55).

We use the fact that 4!1mod54! \equiv -1 \mod 5 and apply it repeatedly. This is based on the property of factorials and modular arithmetic.

First, we need to find 2007!2007! modulo 55:
2007!2mod5 2007! \equiv 2 \mod 5

This is because the product of numbers modulo 55 cycles every 44 numbers (since 4!1mod54! \equiv -1 \mod 5).

Next, we need to consider the powers of 22 modulo 1010. Since 2007!2007! has 500500 trailing zeros, we can ignore these factors of 1010 and focus on the remaining product modulo 1010.

By examining the pattern of the last non-zero digits of factorials, we find that the last non-zero digit of 2007!2007! is 22.

The final answer is 500 \boxed{ 500 } trailing zeros and the last non-zero digit is 22.

Source: NuminaMath-1.5, licensed Apache-2.0. Statement and solution reproduced as published; topic, difficulty and ordering added by this site.