FunctionRacerProblemsRace

Last Digit of a Power

MediumMathPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems