http://www.spoj.com/problems/BORING2/
The problem asks to compute for prime P
where
Unfortunately, doesnt pass!
UPD: I have thought about an alternate approach by calculating factorials using their prime factorization (Legendre's formula). But I am not sure if it is fast enough.