Given two numbers, x and n, return the last d digits of the number that is calculated by x^n. In all cases, d will be the number of digits in x. Keep in mind that the n values in the examples are small, however the test suite values may be much larger. Also, any leading zeros in the final answer should be discounted (If d = 2 and the number ends in 01, just report 1)
Example #1:
- x = 23 (therefore d = 2)
- n = 2;
- 23^2 = 529;
- function will return 29
Example #2:
- x = 123; (therefore d = 3)
- n = 3;
- 123^3 = 1860867;
- function should return 867
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers106
Suggested Problems
-
Return the largest number that is adjacent to a zero
5516 Solvers
-
Sort a list of complex numbers based on far they are from the origin.
5798 Solvers
-
Project Euler: Problem 1, Multiples of 3 and 5
3677 Solvers
-
How many trades represent all the profit?
616 Solvers
-
Golomb's self-describing sequence (based on Euler 341)
183 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
If I'm reading the problem statement right, I think either the answer to test case 2 should be 867 (123^3 = 1860867.) or n=2 (123^2=15129).
James, you are correct. Problem statement and test suite have been fixed.