• + 19 comments

    Here's a solution for Java without having to convert to and from String or Character arrays:

    int n = in.nextInt();
    int r = n;
    int count = 0;
    while(r > 0){
        if(r % 10 != 0 && n % (r % 10) == 0) count++;
        r = r / 10;
    }
    System.out.println(count);