title: Recursive binary search returns correct target, but at the middle index in array
body: <p>Trying out a recursive binary search algorithm, it returns the correct target that I pass it but at the wrong index.</p>
  
  <p>The index seems to always be the center index of the high and low values. </p>
  
  <p>I added some printf's in the binarySearch if statements, and it seams it never calls itself recursively, always returns with the mid value.</p>
  
  <p>Even if you change the target to a value not held within the array, it returns with index 5, and the correct target value.</p>
  
  <pre><code>int main(void)
  {
      int const numbers[10] = {1,3,4,7,13, 14, 17, 18, 20, 23};
      int const target = 20;
      int result = 0;
      result = binarySearch(&amp;numbers, 0, 10, target);
      if (result != -1)
      {
          printf("Element is found in array in index: %d, and holds value: %d\n", result + 1, numbers[result]);
      }
      else
      {
          printf("Element is not found in array\n");
      }
  }
  
  int binarySearch(int* arr, int low, int high, int x)
  {
      if (high &gt;= low)
      {
          int mid = low + (high - low) / 2;
          if (arr[mid] = x)
          {
              printf("mid\n");
              return mid;
          }
          else if (arr[mid] &gt; x)
          {
              printf("high\n");
              return binarySearch(arr, low, mid - 1, x);
          }
          else if (arr[mid] &lt; x)
          {
              printf("low\n");
              return binarySearch(arr, mid + 1 , high, x);
          }   
      }
      else
      {
          return -1;
      }
  }
  </code></pre>
  
  <p>OUTPUT</p>
  
  <pre><code>Element is found in array in index: 5, and holds a value of: 20
  </code></pre>
  
  <p>Thoughts?</p>