Write down all the integers between 1 and 50:
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
Even numbers multiplied by 5 always end in zero. So mark pairs of integers one of which is even and the other a multiple of 5. You can only mark an integer once:
(2×5=10) (4×10=40) (6×15=90) (8×20=160) (12×25=300) (14×30=420) (16×35=560) (18×40=720) (22×45=990) (24×50=1200).
We can represent the integer products as 'ab', where 'a' is an even number and 'b' a multiple of 5. We can use successive even integers for 'a' and successive multiples of 5 for 'b'. However, since we can only use each integer once 'a' cannot be a multiple of 5. So the succession of even integers is 2, 4, 6, 8, 12, ... and 10 is missing because it's a multiple of 5, as is 20. which is also missing.
I've marked all the integers used so far in red. None of the products of the remaining integers have products ending in zero.
Count the number of zeroes in the products. There are 12, so the product of all the integers between 1 and 50 must end in 12 zeroes.
If we want to find out how many zeroes in n! we can work out a method. If n is odd, we can represent it by n=2k+1, so k=(n-1)/2; if n is even then n=2k. k is the number of even integers between 1 and n. For example, k=25 when n=50. But we have to eliminate those even integers which are multiples of 5. The lowest n such that n! ends in zero is when n=5; 10! ends in 2 zeroes; 15! ends in 3 zeroes;
n (factorial) |
z (number of zeroes) |
0-4 |
0 |
5-9 |
1 |
10-14 |
2 |
15-19 |
3 |
20-24 |
4 |
25-29 |
6 |
30-34 |
7 |
35-39 |
8 |
40-44 |
9 |
45-49 |
10 |
50-54 |
12 |
55-59 |
13 |
60-64 |
14 |
65-69 |
15 |
70-74 |
16 |
75-79 |
18 |
80-84 |
19 |
85-89 |
20 |
90-94 |
21 |
The table shows the general pattern. The table predicts that 100! has 24 zeroes at the end.
Let's see if it's right.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
(2×5=10) (4×10=40) (6×15=90) (8×20=160) (12×25=300) (14×30=420) (16×35=560) (18×40=720) (22×45=990) (24×50=1200) (26×55=1430) (28×60=1680) (32×65=2080) (34×70=2380) (36×75=2700) (38×80=3040) (42×85=3570) (44×90=3960) (46×95=4370) (48×100=4800)
If the trailing zeroes are counted we get 24.
The formula [n/5]+[n/25] where the square brackets mean "the integer part of". So if n=78, for example, we have [15.6]+[3.12]=15+3=18, which concurs with the table. This formula only has a limited application as n increases.