# INLO25 - Editorial

#PROBLEM LINK:
[Practice][111]
[Contest][222]
**Author:** [RAVIT SINGH MALIK][4444]
**Editorialist:** [RAVIT SINGH MALIK][6666]
#DIFFICULTY:
MEDIUM - HARD
#PREREQUISITES:
MATHS,NUMBER THEORY
#PROBLEM:
You are required to find the number of trailing ~~zeroes ~~$zeroes$ of F(n) = $1^{1!} \times 2^{2!} \times 3^{3!} $......$N^{N!}$ .
#EXPLANATION:
suppose you have to find the number of zeroes in a product.$ 24 \times 32 \times 23 \times 19$ = $ 2^{3} \times 3^{1} \times 2^{5} \times 23 \times 19 $ as you can notice, this product will have no zeroes because it has no 5 in it.
however, if you have expression like: $23\times39\times32\times125=2^{5}\times3\times5^{3}\times11\times23 $
Zeroes are formed by the combination of $2\times5$. Hence,the number of zeroes will depend on number of pairs of 2's and 5's that can be formed. In the above product, there are five twos and three fives.Hence, ther will be 3 Zeroes in the product.
Find the number of trailing zeroes in 101!
Okay, how many multiples of 5 are there in the numbers from 1 to 101? There's 5, 10, 15, 20, 25,...
Oh, heck; let's do this the short way: 100 is the closest multiple of 5 below 101, and 100 ÷ 5 = 20, so there are twenty multiples of 5 between 1 and 101.
But wait: 25 is 5×5, so each multiple of 25 has an extra factor of 5 that I need to account for. How many multiples of 25 are between 1 and 101? Since 100 ÷ 25 = 4, there are four multiples of 25 between 1 and 101.
Adding these, I get 20 + 4 = 24 trailing zeroes in 101!
How many trailing zeroes would be found in 4617!, upon expansion?
I'll apply the procedure from above:
51 : 4617 ÷ 5 = 923.4, so I get 923 factors of 5
52 : 4617 ÷ 25 = 184.68, so I get 184 additional factors of 5
53 : 4617 ÷ 125 = 36.936, so I get 36 additional factors of 5
54 : 4617 ÷ 625 = 7.3872, so I get 7 additional factors of 5
55 : 4617 ÷ 3125 = 1.47744, so I get 1 more factor of 5
56 : 4617 ÷ 15625 = 0.295488, which is less than 1, so I stop here.
Then 4617! has 923 + 184 + 36 + 7 + 1 = 1151 trailing zeroes.
In the given problem You are required to find the number of trailing zeroes of F(n) = $1^{1!} \times 2^{2!} \times 3^{3!} ......N^{N!}$ so, if n=6
hence no,of twos is $ 2!+2\times4!+2\times6! $ and no. of fives are 5! so,clearly the fives will be less than twos. Hence, we need to count only the fives. Thus: 5!=120
so,thus the f(6) has 120 trailing zeroes.
#AUTHOR'S AND TESTER'S SOLUTIONS:
Author's solution can be found [here][333].
#RELATED PROBLEMS:
[111]: https://www.codechef.com/problems/INLO25
[222]: https://www.codechef.com/INLO2016/problems/INLO25
[333]: https://www.codechef.com/viewsolution/11718340
[4444]: http://www.codechef.com/users/ravit0001
[6666]: http://www.codechef.com/users/ravit0001