An antique car's odometer displays its current reading as an ordinary positive integer with no leading zeros. A digit position on the display is called self-checking if the digit shown there is nonzero and it evenly divides the full odometer reading, leaving no remainder. Zero digits are never self-checking, since dividing by zero is never attempted.
Count how many digit positions on the display are self-checking. A digit value that appears more than once on the display is counted once for every position where it appears, not just once overall.
A single line containing one integer, num, the odometer reading.
Print a single integer: the number of self-checking digit positions in num.
Example 1
Input
1012
Expected
3
Explanation
The digits of 1012 are 1, 0, 1, 2. The 0 is skipped. 1012 % 1 == 0 (first 1), 1012 % 1 == 0 (second 1), and 1012 % 2 == 0, so all three remaining digit positions are self-checking, giving a count of 3.
Example 2
Input
1101
Expected
3
Explanation
The digits of 1101 are 1, 1, 0, 1. The 0 is skipped. Every number is divisible by 1, and there are three occurrences of digit 1, so the count is 3.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →