自除数 是指可以被它包含的每一位数整除的数。

    例如,128 是一个 自除数 ,因为 128 % 1 == 0,128 % 2 == 0,128 % 8 == 0。
    自除数 不允许包含 0 。

    给定两个整数 left 和 right ,返回一个列表,列表的元素是范围 [left, right] 内所有的 自除数 。

    示例 1:

    输入:left = 1, right = 22
    输出:[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]
    示例 2:

    输入:left = 47, right = 85
    输出:[48,55,66,77]

    提示:

    1 <= left <= right <= 104


    1. class Solution {
    2. public List<Integer> selfDividingNumbers(int left, int right) {
    3. List<Integer> res = new ArrayList<>();
    4. for (int i = left; i <= right; ++i)
    5. if (check(i)) res.add(i);
    6. return res;
    7. }
    8. boolean check(int num) {
    9. int t = num;
    10. while (t > 0) {
    11. int tem = t % 10;
    12. if (tem == 0) return false;
    13. if (num % tem != 0) return false;
    14. t /= 10;
    15. }
    16. return true;
    17. }
    18. }