I have learnt from this site that n! modulo p where p is a prime, can be calculated using Wilson's Theorem and FFT with complexity sqrt(p).(log p)^3
There is also a problem using the idea in SPOJ. link
But I am not being able to implement the idea. If anyone have any implementation of the problem please feel free to share.
Thanks for your time. Happy Coding.