Sort by

recency

|

1667 Discussions

|

  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/iTxLvVxH5pY

    int findDigits(int n) {
        int result = 0, original = n;
        while(n){
            int d = n % 10;
            if(d != 0 && original % d == 0) result ++;
            n /= 10;
        }
        return result;
    }
    
  • + 0 comments

    Perl:

    sub findDigits {
        my $n = shift;
        
        my $cnt = 0;
        my @digits = split("", $n);
        foreach (@digits) {
            next if ($_ == 0);
            $cnt++ if ($n % $_ == 0); 
        }
        return $cnt;
    }
    
  • + 0 comments

    can you find mistake in this code plz??

    include

    using namespace std; int main(){ int n; cin>>n; int result = 0; long long int t; for(int i=0;i>t; } while(t--){ int d=t% 10; if(d!=0 && t%d==0 ) result ++;
    } cout<

  • + 0 comments

    Java solution:

    public static int findDigits(int n) {
            String strN = String.valueOf(n);
            
            int count = 0;
            
            for (char c : strN.toCharArray()) {
                int d = Integer.parseInt(String.valueOf(c));
                
                if (d != 0 && n % d == 0) count++;
            }
    
    
            return count;
        }
    
  • + 0 comments

    Here is my Python solution using list comprehensions! The first list is all the digits that are not 0, and the second list is all the numbers in that list that evenly divide the number. We then return the length of that list, which is the amount of numbers that work.

    def findDigits(n):
        digits = [int(digit) for digit in str(n) if int(digit) != 0]
        return len([digit for digit in digits if n % int(digit) == 0])