Hackerrank Find digits error

second test case failing idk why.kindly help

#include<bits/stdc++.h>
using namespace std;

int main()
{
    unsigned long long int t;
    cin>>t;
    while(t--)
    {
        
    unsigned long long int a;
    cin>>a;
    unsigned long long int count=0;
    while(a>0)   
    {
      unsigned long  long int k=a%10;
      if(k==0)
       {
           
       }
      else if(a%k==0 )
       {
           count++;
       }
       a=a/10;
    }    
  cout<<count<<endl;        
    }
    return 0;
}

else if(a%k==0 )
...
a=a/10;

The question asks you to count the number of digits that evenly divide the original value of a, but you keep changing a :slight_smile:

3 Likes

but sir dont we have to update the ‘a’ so that it could generate the next remainder.
please correct me .

You just need to check the divisibility with the original value of a.

2 Likes

Thank you so much sir simon.
passed all the test cases :grin:

1 Like