How ling did you spend trying to understand the answer I gave? a=7 is, shall we say, in the reduced form. The remainder after dividing 7 by 12 is 7.
As it stands, when you say solve a=p mod(n) you are not using a well defined phrase. What you might ought to mean is find the remainder on division by n of p, but that isn't immediately obvious from what you wrote. That is, and I realize I'm just restating what I orginally wrote, find the a with 0<=a<n that is the remainder on dividing by n of p. If a is already in that range you are done.
Remember these aren't equals signs, they are equivalences.