Help in Spoj question EASYFACT

Can anyone help me out in this question EASYFACT?
My solution is passing sample test cases and also test cases from spoj toolkit but getting WA as the final verdict on submission. Here is the link of my solution. Solution