TopCoder problem "DivDigits" used in SRM 148 (Division II Level One)



Problem Statement

    

Create a class DivDigits containing a method howMany which takes as an argument an int number and returns how many digits in number that number itself is divisible by. Count all occurences of such digits in the number, not just the first. See examples for more information.

 

Definition

    
Class:DivDigits
Method:howMany
Parameters:int
Returns:int
Method signature:int howMany(int number)
(be sure your method is public)
    
 

Notes

-No number is divisible by 0.
 

Constraints

-number will be an int between 10000 and 999999999, inclusive (between 5 and 9 digits, inclusive).
 

Examples

0)
    
12345
Returns: 3
12345 is divisible by 1, 3, and 5.
1)
    
661232
Returns: 3
661232 is divisible by 1 and 2.
2)
    
52527
Returns: 0
52527 is not divisible by 5, 2, or 7.
3)
    
730000000
Returns: 0
Nothing is divisible by 0. In this case, the number is also not divisible by 7 or 3.

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=1741

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=4545&pm=1741

Writer:

Unknown

Testers:

PabloGilberto , lbackstrom , brett1479

Problem categories:

Simple Math, String Manipulation