Self Dividing Numbers in Range

MATH

Problem

Create a function that takes two integers, left and right, and returns a list of all self-dividing numbers within the inclusive range [left, right].

A self-dividing number is an integer that is divisible by each of its digits and does not contain the digit 0.

The function should iterate through the range and check each number to determine if it meets the criteria.

Examples

selfDividingNumbers(10, 30) // [11,12,15,22,24] /* Why? - 11 is self-dividing as 11 % 1 == 0 and 11 % 1 == 0. - 12 is self-dividing as 12 % 1 == 0 and 12 % 2 == 0. - 15 is self-dividing as 15 % 1 == 0 and 15 % 5 == 0. - 22 is self-dividing as 22 % 2 == 0 and 22 % 2 == 0. - 24 is self-dividing as 24 % 2 == 0 and 24 % 4 == 0. */ selfDividingNumbers(50, 60) // [55] // Why? 55 is self-dividing as 55 % 5 == 0 and 55 % 5 == 0.
Loading...