I need to find the number of trailing zeroes in $1^{1!} \cdot 2^{2!} \cdot 3^{3!} \cdots N^{N!}$, where $N$ is natural number.
Assuming $N$ is very large, say $500$, where you cannot find factorial of a number. Also, I need to answer by taking modulo with $100000007$.
If $N$ was small then we can simply factorise each number, and see power of $2$ and power of $5$. Whatever is small will be count of trailing zeroes. But how to solve this one ?
EXAMPLE : For $N=7$ answer is $120$, after taking modulo given prime, that is $100000007$.
How to find it for given $N$? What should be algorithm for the same. If there is direct some mathematical formula, then it would be more awesome.