# Leetcode-Easy 728. Self Dividing Numbers

## 728. Self Dividing Numbers

• 描述：
判断一个数是否可以被自己所包含的数整除，如果本身还有0，则不可以

• 思路：
直接遍历判断
• 代码

class Solution:
def selfDividingNumbers(self, left, right):
"""
:type left: int
:type right: int
:rtype: List[int]
"""
self_divide=[]
for i in range(left,right+1):
flag=True
for s in str(i):
if s!='0' and i%int(s)==0:
# print(i,str(i),int(s),i%int(s),i%int(s)==0)
flag=True
else:
flag=False
break
if flag:
self_divide.append(i)
return self_divide

|
12月前
|

|

LeetCode - #2 Add Two Numbers

71 0
LeetCode 357. Count Numbers with Unique Digits

78 0
|

LeetCode 315. Count of Smaller Numbers After Self

89 0
LeetCode 238. Product of Array Except Self

77 0
LeetCode 1380. 矩阵中的幸运数 Lucky Numbers in a Matrix
LeetCode 1380. 矩阵中的幸运数 Lucky Numbers in a Matrix
133 0
LeetCode Contest 178-1365. 有多少小于当前数字的数字 How Many Numbers Are Smaller Than the Current Number
LeetCode Contest 178-1365. 有多少小于当前数字的数字 How Many Numbers Are Smaller Than the Current Number
85 0
LeetCode 5340. 统计有序矩阵中的负数 Count Negative Numbers in a Sorted Matrix
LeetCode 5340. 统计有序矩阵中的负数 Count Negative Numbers in a Sorted Matrix
81 0
|