Skip to content
DeepForgeby svx
All problems
EasyAlgorithmsal-270

Self-Dividing Numbers

Problem

Return the sorted list of numbers in the inclusive range from left to right that are divisible by each of their non-zero digits.

Single-digit numbers are always self-dividing, and the digit 0 is ignored. Test each number in the range directly.

Hint

Zero digits are skipped rather than dividing, which is why 10 counts as self-dividing.

Test cases

case 1
in: [1,22]
expected: [1,2,3,4,5,6,7,8,9,10,11,12,15,20,22]
case 2
in: [47,85]
expected: [48,50,55,60,66,70,77,80]
case 3
in: [10,12]
expected: [10,11,12]
case 4
in: [20,20]
expected: [20]
case 5
in: [21,21]
expected: []
Starter codePython
def self_dividing_numbers(left, right):
    # Your code here
    pass

5 test cases · run your code against them in the editor