Added looping method.
This also calculates the result of an exponentiation.
Added code to enable user to choose method.