Compute aᵇ and return its k-th digit from the right. Peeling digits is easy once you have the number, but the number can be huge. 9⁹⁹ has 95 digits.
Choose the right tool:
- Python integers are arbitrary-precision, so
a ** bjust works - JavaScript has
BigInt:BigInt(a) ** BigInt(b) - C++ / Java need a manual digit array (grade-school multiplication)
Then the k-th digit from the right is (value / 10^(k−1)) % 10, or simply index the string from the end.