Find the smallest integer greater than or equal to a given number whose digit product is divisible by a target value.
Given two integers and , find the smallest integer such that and the product of the digits of is divisible by .
You may assume the answer always exists within the search range used by the original problem.
Input Format
- Two integers and .
- Digits of a number are the decimal digits in its standard representation.
Output Format
- Return the smallest integer whose digit product is divisible by .
Constraints
- The answer is guaranteed to exist for the intended input range.
Example 1
Input
n = 10, t = 2
Output
10
Explanation
The digit product of 10 is 1 \u00d7 0 = 0, and 0 is divisible by 2. Since 10 is already valid, it is the smallest answer.
Example 2
Input
n = 17, t = 5
Output
25
Explanation
17 has digit product 7, which is not divisible by 5. 18, 19, 20, 21, 22, 23, and 24 also fail. For 25, the digit product is 2 \u00d7 5 = 10, which is divisible by 5.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.