Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Problem 1742. Generate a Parasitic Number

Created by James

This problem is the next step up from Problem 156. Rather than determining if an input is a parasitic number, you will be asked to generate one. You will be given the last digit of the number (k), and the number you're using to multiply to shift the parasitic number one digit (n). Both n and k will always be between 1 and 9.

For example, if n=4 and k=7:


So 179487 is a 4-parasitic number with units digit 7.

We are looking for the smallest possible number that meets these criteria, so while 179487, 179487179487, and 179487179487179487 are all valid answers for n=4 and k=7, the correct output for this function is 179487.

Because some of the values that are generated by this function are very large, the output should be a string rather than an integer. Please bear in mind that some of these values will have leading zeros. This will occur when n>k.


Problem Group

Solution Statistics

41 correct solutions 52 incorrect solutions
Last solution submitted on Apr 30, 2016

Problem Comments