Counting the number of leading zeros in n!
from one combination of 2 and 5 we can get one zero,so we have to count the total
number of pairs of 2 and 5 in n! .
exponent of p in n!
floor(n/p)+floor(n/p^2)+floor(n/p^3).......
example- n=10
exponent of 2 in 10!=(10/2)+(10/4)+(10/8)+(10/16)....
=5+2+1+0+0... = 8
exponent of 5 in 10!=(10/5)+(10/25).......
=2+0+0....=2
total combination of (2,5)=min(2,8)
total number of leading zeros in 10!=2
10!=3628800.
Counting the number of digits in n!
log(n!)=log(1)+log(2)+log(3)........log(n).
Counting the number of leading zeros of n! in base b
factorise b=p1^e1*p2^e2*p3^e3...... where p1,p2,p3.. are prime and e1,e2,e3.. are their exponent
then calculate exponent of each prime in n! divided by their exponent and the number of leading zeros of n! in base b is
min(1/e1((n/p1)+(n/p1^2)....),1/e2((n/p2)+(n/p2^2)....),1/e3((n/p3)+(n/p3^2)....).....)
Counting the number of digits of n! in base b
log(n!)/log(b)+1
Good one..
ReplyDelete