Please solve it...and give a optimum solution.
prime numbers greater than 3 are always of the form of 6k+1 or 6k-1. put this in place of p. u will get 1 as remainder always