2025-08-24 10:46:58 +0000 UTC

Smallest Divisible Digit Product I

Code

class Solution:
    def smallestNumber(self, n: int, t: int) -> int:
        while True:
            cur = n
            prd = 1
            while cur > 0:
                prd *= cur % 10
                if prd == 0:
                    break
                cur //= 10
            if prd % t == 0:
                return n
            n += 1