LeetCode solutions

3626. Smallest Divisible Digit Product I

My accepted Python solution to LeetCode problem 3626, Smallest Divisible Digit Product I, running in 1ms.

  • Difficulty: Easy
  • Python
  • Runtime 1ms
  • Memory 17.2MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 1ms, memory 17.2MB, accepted 2025-12-31.

python
class Solution:
    def smallestNumber(self, n: int, t: int) -> int:
        def digit_product(x):
            prod = 1
            while x > 0:
                prod *= x % 10
                x //= 10
            return prod
        
        while digit_product(n) % t != 0:
            n += 1
        return n

Source