Number Theory and Logic!

Find the trailing number of zeros upon the expansion of 123456789 ! 123456789! .

Bonus : Can you generalize this?

Notation : ! ! denotes the factorial notation. For example, 8 ! = 1 × 2 × 3 × × 8 8! = 1\times2\times3\times\cdots\times8 .


The answer is 30864192.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

The number of trailing zeros z ( n ) z(n) of n ! n! is given by:

z ( n ) = k = 1 n 5 k z ( 123456789 ) = k = 1 123456789 5 k = 123456789 5 + 123456789 5 2 123456789 5 3 + . . . + 123456789 5 11 Note that for k 12 , 123456789 5 k = 0 = 24691357 + 4938271 + 987654 + 197530 + 39506 + 7901 + 1580 + 316 + 63 + 12 + 2 = 30864192 \begin{aligned} z(n) & = \sum_{k=1}^\infty \left \lfloor \frac n{5^k} \right \rfloor \\ \implies z(123456789) & = \sum_{k=1}^\infty \left \lfloor \frac {123456789}{5^k} \right \rfloor \\ & = \left \lfloor \frac {123456789}{5} \right \rfloor + \left \lfloor \frac {123456789}{5^2} \right \rfloor \left \lfloor \frac {123456789}{5^3} \right \rfloor + ... + \left \lfloor \frac {123456789}{5^{11}} \right \rfloor & \small \color{#3D99F6}{\text{Note that for }k \ge 12, \ \left \lfloor \frac {123456789}{5^k} \right \rfloor = 0} \\ & = 24691357 + 4938271 + 987654 + 197530 + 39506 \\ & \quad + 7901 + 1580 + 316 + 63 + 12 + 2 \\ & = \boxed{30864192} \end{aligned} .

@Armain Labeeb , it is not a good idea to set a problem with so heavy computation. You can set a Computer Science problem for that. The idea is for others to learn about theory instead of how to use a calculator. Not many will have the patience to do the computation and try your problem. And many may fail to answer the problem not because they don't know how to solve it but because of making mistakes in punching their calculator. I used Wolfram Alpha to check the answer.

Chew-Seong Cheong - 4 years, 11 months ago

Log in to reply

My bad. I will do smaller numbers next time. And by the way, I have not learnt about summation yet, sir so I will post another solution by not using summations.

Armain Labeeb - 4 years, 11 months ago
Armain Labeeb
Jul 6, 2016

A number gets a zero at the end of it if the number has 10 10 as a factor. For instance, 10 10 is a factor of 50 50 , 120 120 , and 1234567890 1234567890 etc.. So I need to find out how many times 10 10 is a factor in the expansion of 123456789 ! 123456789! .

But since 5 × 2 = 10 5×2 = 10 , All the products of 5 5 and 2 2 needs to be taken account of. Looking at the factors in the expansion, there are many more numbers that are multiples of 2 2 ,i.e., ( 2 , 4 , 6 , 8 , 10 , 12 , 14 , ) (2, 4, 6, 8, 10, 12, 14,\dots) than are multiples of 5 5 ,i.e., ( 5 , 10 , 15 , ) (5, 10, 15,\dots) . That is, if all the numbers with 5 5 as a factor is taken, there will be way more than enough even numbers (multiples of 2 2 ) to pair with them to get factors of 10 10 (and another trailing zero on the factorial). So to find the number of times 10 10 is a factor, all I really need to worry about is how many times 5 5 is a factor in all of the numbers between 1 1 and 123456789 123456789 .

The largest multiple less than 123456789 123456789 is 123456785 123456785 . So the number of multiples of 5 5 between 1 1 and 123456789 123456789 is 123456785 ÷ 5 = 24691351 123456785\div5\,=\,24691351 .

But, 25 = 5 × 5 25\,=\,5\,\times\,5 , so each multiple of 25 25 has an extra factor of 5 5 , which also needs to be taken account of. 123456789 ÷ 25 = 4938271.56 123456789\,\div\,25\,=\,4938271.56 . So there are 4938271 4938271 factors of 25 25 between 1 1 and 123456789 123456789 .

In this way, we arrive at a general rule:

  • Take the number that you've been given the factorial of.
  • Divide by 5 5 ; if a decimal is obtained, truncate to a whole number.
  • Divide by 5 2 = 25 5^{2} = 25 ; if a decimal is obtained, truncate to a whole number.
  • Divide by 5 3 = 125 5^{3} = 125 ; if a decimal is obtained, truncate to a whole number.
  • Continue with higher powers of 5 5 , until the division results in a number less than 1. Once the division is less than 1, stop.
  • Sum all the whole numbers obtained from the divisions. This is the number of trailing zeroes.

Using the above procedure , we have:

123456789 ÷ 5 1 = 24691357.8 123456789 ÷ 5 2 = 4938271.56 123456789 ÷ 5 3 = 987654.312 123456789 ÷ 5 4 = 197530.8624 123456789 ÷ 5 5 = 39506.17248 123456789 ÷ 5 6 = 7901.234496 123456789 ÷ 5 7 = 1580.264899 123456789 ÷ 5 7 = 316.0493798 123456789 ÷ 5 8 = 63.20987597 123456789 ÷ 5 9 = 12.64197519 123456789 ÷ 5 10 = 2.528395039 \begin{aligned} 123456789\, \div \, 5^{ 1 }\, \, & =24691357.8 \\ 123456789\, \div \, 5^{ 2 }\, \, & =\, \, \, 4938271.56 \\ 123456789\, \div \, 5^{ 3 }\, \, & =\, \, \, \, \, \, 987654.312 \\ 123456789\, \div \, 5^{ 4 }\, \, & =\, \, \, \, \, 197530.8624 \\ 123456789\, \div \, 5^{ 5 }\, \, & =\, \, \, \, \, \, \, \, 39506.17248 \\ 123456789\, \div \, 5^{ 6 }\, \, & =\, \, \, \, \, \, \, \, \, \, \, 7901.234496 \\ 123456789\, \div \, 5^{ 7 }\, \, & =\, \, \, \, \, \, \, \, \, \, 1580.264899 \\ 123456789\, \div \, 5^{ 7 }\, \, & =\, \, \, \, \, \, \, \, \, \, \, \, \, 316.0493798 \\ 123456789\, \div \, 5^{ 8 }\, \, & =\, \, \, \, \, \, \, \, \, \, \, \, \, \, \, \, 63.20987597 \\ 123456789\, \div \, 5^{ 9 }\, \, & =\, \, \, \, \, \, \, \, \, \, \, \, \, \, \, \, 12.64197519 \\ 123456789\, \div \, 5^{ 10 }\, \, & =\, \, \, \, \, \, \, \, \, \, \, \, \, \, \, \, \, \, \, 2.528395039 \\ & \end{aligned}

The number of trailing zeros is the sum of the the above divisions after their answer is truncated .

So if k k is the number of trailing zeroes,

k = 24691357 + 4938271 + 987654 + 197530 + 39506 + 7901 + 1580 + 316 + 63 + 12 + 2 = 30864192 \large{\begin{aligned} k\quad & =24691357+4938271+987654+197530+39506+7901+1580+316+63+12+2 \\ & =\boxed { 30864192 } \end{aligned}}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...