JuniorMath

Count the Digits That Divide a Number

Given an integer num, return the number of digits in num that divide num.

An integer val divides nums if nums % val == 0.

Example 1
Inputnum = 7
Output1
7 divides itself, hence the answer is 1.
Example 2
Inputnum = 121
Output2
121 is divisible by 1, but not 2, and since 1 occurs twice as a digit, we return 2.

Constraints

  • 1 <= num <= 10^9
  • num does not contain 0 as one of its digits.

Asked at 3 companies

Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, what to keep, what's wrong, and the complexity of your solution.

Sign in to evaluate