Self Dividing Numbers

A self-dividing number is divisible by every one of its digits, and it may not contain the digit 0. For example, 128 is self-dividing because 128 % 1, 128 % 2 and 128 % 8 are all 0. Given two integers left and right, return every self-dividing number in the range [left, right], in increasing order.

30:00

Self Dividing Numbers
easy
Free written solution
Topics
Companies

A self-dividing number is divisible by every one of its digits, and it may not contain the digit 0. For example, 128 is self-dividing because 128 % 1, 128 % 2 and 128 % 8 are all 0. Given two integers left and right, return every self-dividing number in the range [left, right], in increasing order.

Example 1:
Input: {"left":1,"right":22}
Output: [1,2,3,4,5,6,7,8,9,11,12,15,22]
Constraints:
  • 1≤left≤right≤1041 \leq \text{left} \leq \text{right} \leq 10^4

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"left":1,"right":22}

Test every number from 1 to 22: it must be divisible by each of its own digits, and no digit may be 0.

range [1, 22]
checked 0/22

digit test

waiting for the first number

number line

nothing decided yet

result (0)

[]
Variables
VariableValue
left1
right22
DepthFunction Call
Stack empty
0/73