-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeetCode_728.py
More file actions
40 lines (39 loc) · 852 Bytes
/
LeetCode_728.py
File metadata and controls
40 lines (39 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class Solution:
def selfDividingNumbers(self, left, right):
"""
:type left: int
:type right: int
:rtype: List[int]
"""
list=[]
for i in range(left, right+1):
if (subself(self,i)):
list.append(i)
return list
def subself(self,n):
a = str(n)
num = 0
for i in a:
if int(i) == 0:
continue
if (n % int(i) == 0):
num += 1
if (num==len(a)):
return True
else:
return False
def a(left, right):
res = []
for i in range(left, right + 1):
d = i
while (d):
j = d % 10
if not j:
break
if i % j:
break
d=d//10
if not d:
res.append(i)
return res
print(a(1,22))