Easily Check if a Big Number is a Power of 3 in Python