Sort by

recency

|

1659 Discussions

|

  • + 0 comments

    java15:

    import java.util.*;

    public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int number; String napis; int divDigit=0;

        for(int i =0;i<n;i++){
            number = scanner.nextInt();
            napis = String.valueOf(number);
            String[] arrayString= napis.split("");
            int[] array = new int[napis.length()];
    
            for(int j=0;j<napis.length();j++){
            array[j]=Integer.parseInt(arrayString[j]);
            if(array[j]!=0&&number%array[j]==0) divDigit++;
            }
            System.out.println(divDigit);
            divDigit=0;
        }
    
    
    
    }
    
  • + 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

    Solution from my side -

    def findDigits(n):
        numList = list(str(n))
        count = 0
        for item in numList:
            if(int(item) != 0):
                if(n%int(item) == 0):
                    count +=1
        return count
    
  • + 0 comments

    Hi I figure it out how to do this in a straigth foward way with some convertions

     public static int findDigits(int n) {
            
        // Write your code here
        String n2 = Integer.toString(n);
        ArrayList<Integer> nuevo = new ArrayList<>();
        int contador=0;
        
       for(char l: n2.toCharArray()){
           int x = Character.getNumericValue(l);
           nuevo.add(x);
       }
       
       for (int n3 : nuevo){
        
        if (n3 !=0 && n%n3 ==0)
            contador ++;
       }
        System.out.println(nuevo);
        return contador;
        }
    
    }
    
  • + 0 comments
    int dividers = 0 ; 
            int digit = 0 ;
            int originalNumber =n;
            try{    
                while(n != 0){
                    digit = n % 10;
                    if(digit != 0 &&originalNumber%digit==0)
                        dividers++;
                    n = n/10;
                }
                
            }catch(Exception exception){
                System.out.println(exception);
            }
            return dividers;