def sqrtAndMultply(self, P, Pp, n):
    'return P**n using square and multiply technique'
    if (n == 0):
        return self.one()
    elif (n == 1):
        return P
    elif ((n % 2) == 1):
        Q = self.sqrtAndMultply(P, Pp, ((n - 1) / 2))
        return (P * self.square(Q))
    elif ((n % 2) == 0):
        Q = self.sqrtAndMultply(P, Pp, (n / 2))
        return self.square(Q)
return P**n using square and multiply technique
def sqrtAndMultply(self, P, Pp, n):
    
    if (n == 0):
        return self.one()
    elif (n == 1):
        return P
    elif ((n % 2) == 1):
        Q = self.sqrtAndMultply(P, Pp, ((n - 1) / 2))
        return (P * self.square(Q))
    elif ((n % 2) == 0):
        Q = self.sqrtAndMultply(P, Pp, (n / 2))
        return self.square(Q)