Ctrl K

Numbers Divisible by Their Own Digits

Easy
Call a number *self-divisible* if it is evenly divisible by every one of its digits. For example, 36 is self-divisible: it divides by both 3 and 6. A number containing the digit 0 is never self-divisible, since you cannot divide by zero. Given two integers low and high, return all self-divisible numbers from low to high inclusive, in increasing order.
Example 1
low=10, high=30 → [11, 12, 15, 22, 24]

For example, 24 divides by both 2 and 4, while 20 is out because of its zero and 13 because it does not divide by 3.

Example 2
low=5, high=9 → [5, 6, 7, 8, 9]

A one-digit number always divides by itself, so all of them qualify.

Example 3
low=101, high=110 → []

Every number from 101 to 110 contains the digit 0, so the answer is empty.

Constraints
  • 1 ≤ low ≤ high ≤ 10⁴
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsA Number That Reads Both Ways EasyValue of a Roman Numeral EasyAdd One to a Digit Array EasySum of Binary Strings EasyWhole Square Root Easy
loading Python…
Input
low=10, high=30
Expected
[11, 12, 15, 22, 24]

Run checks the first 3 tests in your browser. Submit checks all 81 tests on the server, hidden ones included.