I am trying to find most optimized formula for achieving following result.
For example, There is a number 125. I need to change its tenth which is '2' to '7', resulting 175.
One formula that I derived:
= 125 + {(7 - (125 / 10 % 10)} * 10
= 125 + (7 - 2) * 10
= 125 + 50
= 175
But, what if I have to change unit or hundred or x digit of a number?