Looks like earlier I have added a line note at the wrong place. I took a look http://www.numbertheory.org/php/squareroot.html
shouldn't this be the case gcd(a, p**n) = p**n?