implement integer reversal using all the maths