{"id":230,"date":"2018-09-21T19:44:54","date_gmt":"2018-09-21T11:44:54","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=230"},"modified":"2018-11-29T14:45:51","modified_gmt":"2018-11-29T06:45:51","slug":"728-self-dividing-numbers","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=230","title":{"rendered":"728. Self Dividing Numbers"},"content":{"rendered":"<p>A\u00a0<i>self-dividing number<\/i>\u00a0is a number that is divisible by every digit it contains.<\/p>\n<p>For example, 128 is a self-dividing number because\u00a0<code>128 % 1 == 0<\/code>,\u00a0<code>128 % 2 == 0<\/code>, and\u00a0<code>128 % 8 == 0<\/code>.<\/p>\n<p>Also, a self-dividing number is not allowed to contain the digit zero.<\/p>\n<p>Given a lower and upper number bound, output a list of every possible self dividing number, including the bounds if possible.<\/p>\n<p><b>Example 1:<\/b><\/p>\n<pre><b>Input:<\/b> \r\nleft = 1, right = 22\r\n<b>Output:<\/b> [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]\r\n<\/pre>\n<p><b>Note:<\/b><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>The boundaries of each input argument are\u00a0<code>1 &lt;= left &lt;= right &lt;= 10000<\/code>.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def selfDividingNumbers(self, left, right):\r\n        &quot;&quot;&quot;\r\n        :type left: int\r\n        :type right: int\r\n        :rtype: List[int]\r\n        &quot;&quot;&quot;\r\n        a = []\r\n        for i in range(left, right + 1):\r\n            if self.isDN(i):\r\n                a.append(i)\r\n        return a\r\n            \r\n            \r\n    def isDN(self, num):\r\n        if str(0) in str(num):\r\n            return False\r\n        for i in str(num):\r\n            if num % int(i) != 0:\r\n                return False\r\n        return True\r\n        \r\n        \r\n        \r\n        \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A\u00a0self-dividing number\u00a0is a number that is divisible by<a href=\"https:\/\/www.ccagml.com\/?p=230\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">728. Self Dividing Numbers<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/230"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=230"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/230\/revisions"}],"predecessor-version":[{"id":231,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/230\/revisions\/231"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}