魔法师 (@Constanline)Leetcode每日一题 —— 3345. 最小可整除数位乘积 I 中发帖

思路
暴力解题,因为乘积为0的时候一定可以整除,所以最多尝试10次。 
代码
class Solution {
    public int smallestNumber(int n, int t) {
        for (int i = n; ; i++) {
            int prod = 1;
            int x = i;
            while (x != 0) {
                prod *= x % 10;
                x /= 10;
            }
            if (prod % t == 0) {
                return i;
            }
        }
    }
}
 
 
Back to Top