Problem 3077. Big numbers, least significant digits
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
-
2 Comments
James
on 12 Mar 2015
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).
Michael C.
on 13 Mar 2015
James, you are correct. Problem statement and test suite have been fixed.
Solution Comments
Show commentsGroup

Matrix Manipulation I
- 16 Problems
- 98 Finishers
- Remove the air bubbles
- Remove NaN ?
- N-Dimensional Array Slice
- Back to basics 21 - Matrix replicating
- Back to basics 23 - Triangular matrix
- Make an awesome ramp for a tiny motorcycle stuntman
- Flip the main diagonal of a matrix
- surrounded matrix
- Some Assembly Required
- Set some matrix elements to zero
- Matrix with different incremental runs
- Removing rows from a matrix is easy - but what about inserting rows?
- Rotate input square matrix 90 degrees CCW without rot90
- Permute diagonal and antidiagonal
- Operate on matrices of unequal, yet similar, size
- Reverse the elements of an array
Problem Recent Solvers95
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!