Magicsheet logo

Smallest Divisible Digit Product I

Easy
75%
Updated 8/1/2025

Asked by 1 Company

Smallest Divisible Digit Product I

What is this problem about?

The "Smallest Divisible Digit Product I" interview question is a math-based challenge that asks you to find the smallest number greater than or equal to a given integer n such that the product of its digits is divisible by a target integer t. This "Smallest Divisible Digit Product I coding problem" requires iterating through numbers and performing basic digit manipulation.

Why is this asked in interviews?

Accenture and other companies use this question to test basic loop constructs, number manipulation, and modulo arithmetic. It's an "EASY" level problem that evaluates if a candidate can write clean, bug-free logic for repetitive tasks. It also tests the ability to break a number into its component digits and calculate a product.

Algorithmic pattern used

The pattern is "Math and Enumeration interview pattern". Since you are looking for the smallest such number, you can simply start from n and increment by 1. For each number, calculate the product of its digits. If the product is divisible by t (i.e., product % t == 0), you've found your answer.

  1. Start at x = n.
  2. While True:
    • Calculate digit product of x.
    • If product % t == 0, return x.
    • x = x + 1.

Example explanation

Let n = 10, t = 2.

  1. Check 10: Digits 1, 0. Product = 1 * 0 = 0. 0 % 2 == 0. Return 10. Let n = 15, t = 10.
  2. Check 15: Product 1 * 5 = 5. Not divisible by 10.
  3. Check 16: Product 1 * 6 = 6. Not divisible by 10. ...
  4. Check 25: Product 2 * 5 = 10. Divisible by 10! Return 25.

Common mistakes candidates make

A common mistake is forgetting that any number containing the digit '0' will have a digit product of 0. Since 0 is divisible by any non-zero t, numbers with '0' are often the answer. Another mistake is an inefficient way of extracting digits (using string conversion instead of math). While string conversion works, using % 10 and / 10 is generally preferred in technical interviews for "Smallest Divisible Digit Product I interview question".

Interview preparation tip

For small-range enumeration problems, a simple while loop is your best friend. Always be mindful of the special property of the number 0 in multiplication. Understanding how to peel digits off a number using arithmetic is a core skill you should master early in your preparation.

Similar Questions