Below is the code to find 0 in a number for
Example : 1701 has 0, 1711 has no zero.If the number is a single digit it will print "Not possible".
The problem of the code is that if the number is like 666 then 'solve(num)' get executed 3 times whereas it should be executed only once and if the number is 505 then 'solve num' gets executed once whereas it shouldn't be executed as the number 505 has zero in it.
private void match(int num) {
int length=(int) (Math.log10(num)+ 1);
if(length==1){
System.out.println("Not possible");
}
else{
if(num%10!=0){
char n[]=new char[length];
String number = String.valueOf(num);
char[] digits1 = number.toCharArray();
for(int i=0;i<number.length();i++){
// n[i]=(Character.valueOf((char) digits1[i]));
if((Character.valueOf((char) digits1[i]))!='0'){
solve(num);
}
}
}
}
}