title: Decompose integer into two bytes
body: <p>I'm working on an embedded project where I have to write a time-out value into two byte registers of some micro-chip.</p>
  
  <p>The time-out is defined as:</p>
  
  <pre><code>   timeout = REG_a * (REG_b +1)
  </code></pre>
  
  <p>I want to program these registers using an integer in the range of 256 to lets say 60000. I am looking for an algorithm which, given a timeout-value, calculates REG_a and REG_b. </p>
  
  <p>If an exact solution is impossible, I'd like to get the next possible larger time-out value.</p>
  
  <p><strong>What have I done so far:</strong></p>
  
  <p>My current solution calculates:</p>
  
  <pre><code>   temp = integer_square_root (timeout) +1;
     REG_a = temp;
     REG_b = temp-1;
  </code></pre>
  
  <p>This results in values that work well in practice. However I'd like to see if you guys could come up with a more optimal solution.</p>
  
  <p>Oh, and I am memory constrained, so large tables are out of question. Also the running time is important, so I can't simply brute-force the solution.</p>