If you want to work out such tricks it often helps to do it algebraically for a general case.
Your first example. Say the person is ab years old, that's the same as 10*a + b.
a*5 = 5a (your use of equal signs as "execute" are a deadly sin to a mathematician by the way.)
(5a + 3) *2 = 10a + 6
10a + 6 + b  6 = 10a + b
