You don’t need to care about the precision of your answer, it’s acceptable if the expected answer and your answer ‘s difference is smaller than
x n pow(x, n)
2.1 3 9.261
0 1 0
1 0 1
The following implements the exponentiation by squaring algorithm, which is described here.