[Tutor] help with this problem

Ratna Banjara mast.ratna at gmail.com
Sun Apr 24 12:28:22 CEST 2011


 The number 124 has the property that it is the smallest number whose
first three multiples contain the digit 2. Observe that
124*1 = 124, 124*2 = 248, 124*3 = 372 and that 124, 248 and 372 each
contain the digit 2. It is possible to generalize this property to be
the smallest number whose first n multiples each contain the digit 2.
Write a function named smallest(n) that returns the smallest number
whose first n multiples contain the digit 2. Hint: use modulo base 10
arithmetic to examine digits.

Its signature is
int smallest(int n)

You may assume that such a number is computable on a 32 bit machine,
i.e, you do not have to detect integer overflow in your answer.

-- 
Regards,
Ratna P Banjara


More information about the Tutor mailing list