leetcode 728:Self Dividing Numbers with Python
阿新 • • 發佈:2018-12-18
class Solution: def selfDividingNumbers(self, left, right): """ :type left: int :type right: int :rtype: List[int] """ listres = [] for i in range(left,right+1): if self.isD(i): listres.append(i) return listres def isD(self,digit): string = str(digit) list1 = list(string) if '0' in list1: return False else: for i in list1: j = int(i) if digit%j != 0: return False return True