Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions Recursion 1/CountZero.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ public class solution {

public static int countZerosRec(int input){
// Write your code here
if(input == 0)
return 0;
if(input % 10 == 0){
return countZerosRec(input / 10) + 1;
}
else{
return countZerosRec(input / 10);
}
if(input/10 == 0) {

if(input == 0) {
return 1;
}
return 0;
}



int smallAns = countZerosRec(input/10);
if(input % 10 == 0) {
return smallAns + 1;
}
return smallAns;
}

public static void main(String[] args) {
Expand Down