Smallest Divisible Digit Product I

You are given two integers `n` and `t`. Return the **smallest** number greater than or equal to `n` such that the **product of its digits** is divisible by `t`.

30:00

Smallest Divisible Digit Product I
easy
Free written solution
Topics
Companies

You are given two integers n and t.

Return the smallest number greater than or equal to n such that the product of its digits is divisible by t.

Example 1:
Input: {"n":10,"t":2}
Output: 10
Constraints:
  • 1≤n≤1001 \leq n \leq 100

  • 1≤t≤101 \leq t \leq 10

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"n":10,"t":2}

Start at x = n = 10 and count upward until the product of x's digits is a multiple of t = 2.

n = 10, t = 2, candidate x = n + 0

1
0

p = product of digits

Variables
VariableValue
n10
t2
x10
DepthFunction Call
Stack empty
0/3