computes power a^n in O(log n) mults

removed useless variables
computes a^n in O(log n) mults