Last Digit of a Power
Return the last decimal digit of a raised to the power b. Note that a ** 0 is 1. The numbers can be too large to compute directly, so look for a cycle in the last digits.
Example 1
a 7
b 4
returns 1
7**4 = 2401.
Example 2
a 2
b 0
returns 1
Anything to the power 0 is 1.
Constraints
0 <= a <= 10**90 <= b <= 10**9
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Last Person StandingMedium
- Minimum Moves to Equal ElementsMedium
- Multiply StringsMedium
- Power ModMedium
- Trailing Zeroes in FactorialMedium
- Twin PrimesMedium
- Valid SquareMedium
- Can the Pair Be ReachedHard