Problem Link: http://www.spoj.com/problems/DCEPC11B/I solved this problem using Wilson's theorem and Fermat's Little Theorem(to find inverse modulo).Is there a better way?There must be because there are solutions that are 10 times faster than mine!
Yes there's a really fast method to solve this problem .Me too solve this using Wilson's theorem