← ALL NOTES
Math

3345. Smallest Divisible Digit Product I

The distances here are tiny, so I scan upward from n and stop at the first number whose digit product is divisible by t. That reads like the lazy option, but the constraints make it the correct one: n <= 100, t <= 10, and any number ending in 0 has a digit product of 0, which is divisible by every t. The answer is never more than a few steps away.

Loading…