diff --git a/Recursion 1/Count Zeroes b/Recursion 1/Count Zeroes index ca40b10..b2e77c6 100644 --- a/Recursion 1/Count Zeroes +++ b/Recursion 1/Count Zeroes @@ -6,14 +6,15 @@ using namespace std; int countZeros(int n) { - // Write your code here - if(n==0) + if(n/10==0 && n%10==0) + return 1; + else if (n/10==0) return 0; - int rem=n%10; - if(rem==0) - return 1+countZeros(n/10); + int ans=countZeros(n/10); + if(n%10==0) + return ans+1; else - return countZeros(n/10); + return ans; } int main() { int n;