fast-exponentiation-algs homework on Java