Count Digits

Practice this coding question on Coding Gurukul.

Problem statement

An archive uses the decimal digits of a positive record number as candidate batch sizes. A digit qualifies when records can be divided into batches of that size without a remainder. Your task Count the nonzero digits of n that divide n exactly. Important details Test each digit against the original number, not a shortened value produced while extracting digits. Ignore zero because division by zero is undefined. Repeated digits are separate candidates and each qualifying occurrence contributes one. This problem counts divisors among the digits; it does not ask for the total number of digits. Worked example For 1012, both occurrences of 1 divide 1012, zero is ignored, and 2 also divides 1012. The answer is 3.

Input format

One positive integer n.

Output format

Print the count of qualifying digit occurrences.

Constraints

1 <= n <= 1000000000.

Sample input

1012

Sample output

3

Sign in to run or submit a solution in C++, Java or Python.

Loading Coding Gurukul…