PROBLEM LINK:Author: RAVIT SINGH MALIK DIFFICULTY:MEDIUM  HARD PREREQUISITES:MATHS,NUMBER THEORY PROBLEM:You are required to find the number of trailing $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. 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 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. RELATED PROBLEMS:
This question is marked "community wiki".
asked 10 Oct '16, 13:06

include<math.h>include<stdio.h>int main(){ int t; scanf("%d",&t); int m,i,j,fact=1,f=1; for(i=1;i<=t;i++){ scanf("%d",&m); } for(j=1;j<=m;j++){ fact=factj; f=fpow(m,fact); fact=fact; printf("%d\n",f); } return 0; } answered 23 Dec '17, 08:19

include<stdio.h>define MAX 10004define MOD 1000000007typedef long long ll; ll fact[1007]; int main(){ ll t; scanf("%lld",&t); fact[1]=1; fact[0]=1; for(ll i=1;i<=500;i++) fact[i]=(fact[i1]i)%100000007; while(t){ ll n; ll ans=0; scanf("%lld",&n); if(nn%2<nn%5) { ll i=2; while(i<=n) { for(ll j=i;j<=n;j+=i) { ans=(ans+fact[j])%100000007; } i=2; } } else { ll i=5; while(i<=n) { for(ll j=i;j<=n;j+=i) { ans=(ans+fact[j])%100000007; } i*=5; } } printf("%lld\n",ans); } return 0; } answered 28 Dec '17, 08:17
