Find Digits
Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,i;
cin>>t; // input test cases
for(i=0;i<t;i++)
{
int n,x,y,j,count=0;
cin>>n; //input number is taken
x=n; // value of n is saved in x temporarily
do
{
y=x%10; // one by one digit of number n Is saved in y to check divisibility
x=x/10;
if(y==0) // if y is 0 then it cannot divide any number hence continue
{
continue;
}
if(n%y==0) // if y completely divide n then increase the count value by 1
{
count++;
}
}while(x!=0);
cout<<count<<endl; // number of digits of n which evenly divide n is printed as output
}
return 0;
}
Find Digits Hackerrank Solution in C++
Find Digits Hackerrank Solution in Cpp
0 Comments