#2520
Count the Digits That Divide a Number
newbie · 115 · lc easy +12 · verified · 85.9% accepted · 673 likes · top 97%
Description
Given a positive integer num, count how many of its individual digits evenly divide num (i.e., num % digit == 0). Return that count.
Example 1:
Input: num = 7
Output: 1
Explanation: 7 divides itself, hence the answer is 1.
Example 2:
Input: num = 121
Output: 2
Explanation: 121 is divisible by 1, but not 2. Since 1 occurs twice as a digit, we return 2.
Example 3:
Input: num = 1248
Output: 4
Explanation: 1248 is divisible by all of its digits, hence the answer is 4.
Code
1
2
3