repeated squaring in python