title: Number of even divisors using square root
body: <p>I'm solving an problem where it need to get the difference between the number of even and odd divisors ,and i need to use sqrt() function because the limit of the number is 10^9 so looping on the whole number is not an option cause of the time limit exceed.</p>
  
  <p>this a function I tried to make but it doesn't work perfectly on all number.</p>
  
  <p>Ex. 4 &amp; 48745.</p>
  
  <p>Case 4 : should output 2 even divisors {2,4} and 1 odd divisor {1} -- the below function output 3 even 1 odd</p>
  
  <p>Case 48745 :should output 0 even divisors and 4 odd divisors {1,5,9749,48745} -- the below function output 2 even 2 odd </p>
  
  <pre><code>int di(int x)
  {
      int even=0,odd=0;
      for(int i=1;i&lt;=sqrt(x);i++)
      {
          if(x%i==0)
          {
              if(i%2)
                  odd++;
              else
                  even++;
          if(x/i %2==0 &amp;&amp; x/i!=i)
              even++;
          else if(x/i!=i)
              odd++;
          }
      }
      return even-odd;
  }
  </code></pre>