title: Count number of digits recursively
body: <p>In order to learn recursion, I want to count the number of decimal digits that compose an integer. For didactic purposes, hence, I would like to not use the functions from <code>math.h</code>, as presented in:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/3068397/finding-the-length-of-an-integer-in-c">Finding the length of an integer in C</a></li>
  <li><a href="https://stackoverflow.com/questions/1068849/how-do-i-determine-the-number-of-digits-of-an-integer-in-c">How do I determine the number of digits of an integer in C?</a> .</li>
  </ul>
  
  <p>I tried two ways, based on the assumption that the division of an integer by <code>10</code> will, at a certain point, result in <code>0</code>.</p>
  
  <p>The first works correctly. <code>count2(1514, 1)</code> returns <code>4</code>:</p>
  
  <pre><code>int count2(int n, int i){
          if(n == 0)
                  return 0;
          else
                  return i + count2(n / 10, i);
  }
  </code></pre>
  
  <p>But I would like to comprehend the behavior of this one:</p>
  
  <pre><code>    int count3(int n, int i){
              if(n / 10 != 0)
                      return i + count3(n / 10, i);
      }
  </code></pre>
  
  <p>For example, from <code>count3(1514, 1);</code> I expect this:</p>
  
  <pre><code>1514 / 10 = 151;        # i = 1 + 1 
  151  / 10 = 15;         # i = 2 + 1
  15   / 10 = 1;          # i = 3 + 1
  1    / 10 = 0;          # Stop!
  </code></pre>
  
  <p>Unexpectedly, the function returns <code>13</code> instead of <code>4</code>. Should not the function recurse only 3 times? What is the actual necessity of a base case of the same kind of <code>count2()</code>?  </p>