Big numbers, least significant digits - MATLAB Cody - MATLAB Central

Problem 3077. Big numbers, least significant digits

Difficulty:Rate

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

42.8% Correct | 57.2% Incorrect
Last Solution submitted on Jan 27, 2025

Problem Comments

Solution Comments

Show comments

Group

Project Euler II Image
Project Euler II
  • 12 Problems
  • 51 Finishers

Problem Recent Solvers95

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page