Begin27. Given a number \(A\). Compute \(A^8\) using the auxiliary variable and three operations of multiplication. To do this, we must sequentially find \(A^2, A^4, A^8\). Display all found powers of \(A\).

Solution in Python 3:

import random

A = random.randrange(0, 10)
#A = 2
print("A = ",A)
A = A*A
print("A^2 = ",A)
A = A*A
print("A^4 = ",A)
A = A*A
print("A^8 = ",A)