title: Modify Nth Digit
body: <p>Given a number, I want to modify the Nth digit of the number.</p>
  
  <p>For example, given 1237645, I want to change the 4<sup>th</sup> digit from the right, which is 7 in this case, to say 5.</p>
  
  <p>The only way in which I can think of is to do this</p>
  
  <pre><code>N = 1237645
  fourthDigit = (N / 1000) % 10    
  N -= fourthDigit * 1000       // make fourth digit 0
  N += 5 * 1000                 // make fourth digit 5
  </code></pre>
  
  <p>But this is quite inefficient. Is there a better way to this? I cannot use array to represent N due to memory constraints.</p>