a^n computation