Self Dividing Numbers

EasyMathmath

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

A self-dividing number is a positive integer that is divisible by every one of its digits. For example, 128 is self-dividing because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. A number containing the digit 0 is never self-dividing. Given two integers left and right, return a list of all self-dividing numbers in the inclusive range [left, right], in increasing order.

Examples

Input: left = 1, right = 22
Output: [1,2,3,4,5,6,7,8,9,11,12,15,22]
10, 20, and 21 fail (a zero digit, or 21 % 2 != 0), among others.
Input: left = 47, right = 85
Output: [48,55,66,77]
For example 48 % 4 == 0 and 48 % 8 == 0.

Constraints

  • 1 <= left <= right <= 10^4

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More math problems