All problems
0767EasyMath

Digits That Divide The Reading

Tracked in this browser only
Write code

Trains the technique from

LeetCode 2520Count the Digits That Divide a Number

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A meter shows a positive whole number reading.

Walk the decimal digits of reading from left to right. A digit carries when the reading divides by that digit with no remainder. A digit equal to 0 never carries, since nothing divides by zero.

Return how many digit positions carry. A digit that appears more than once is counted once for each position it occupies.

Examples

Example 1

Input
reading = 4620
Output
3

4620 divides evenly by 4, by 6 and by 2, so those three positions carry. The final digit is 0 and never carries.

Example 2

Input
reading = 305
Output
1

305 leaves a remainder of 2 when divided by 3, the middle digit is 0 and cannot carry, and 305 divides evenly by 5. One position carries.

Example 3

Input
reading = 936
Output
3

936 divides evenly by 9, by 3 and by 6, so all three positions carry.

Constraints

  • 1 <= reading <= 10^9

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def dividing_digits(reading: int) -> int:
Java
public int dividingDigits(int reading)
September 7
Apply