I would use the modulo operator (%) and division for this. Modulo gives you the remainder of integer division so 100 % 10 = 0. So if 100 % 10 = 0 then you need to get rid of the rightmost 0 by division. Divsion by 10 will do that. Put it together and you need a while loop that checks if the value modulo 10 is 0 and then in the body of the loop you need to trim off that zero using division by 10.