diff --git a/Recursion 1/Count Zeroes b/Recursion 1/Count Zeroes index ca40b10..060b7aa 100644 --- a/Recursion 1/Count Zeroes +++ b/Recursion 1/Count Zeroes @@ -20,3 +20,23 @@ int main() { cin >> n; cout << countZeros(n) << endl; } + + +//other approach - + +int countZeros(int n) { + // Write your code here + if(n <=0){ + return 1; + } + if(n<10) return 0; + //else{ + // return 0; + // } + int smallAns = countZeros(n/10); + if(n%10 == 0){ + smallAns = smallAns+1; + } + return smallAns; + +}