// $%$ is the remainder operation, e.g. // 15 divided by 2 is 7 with remainder 1, so 15 % 2 = 1, and // 1 divided by 2 is 0 with remainder 1, so 1 % 2 = 1, and // 16 divided by 2 is 8 with remainder 0, so 16 % 2 = 0. int n = 19; int x = 0; int y = 1; while (n != 0) if (n % 2 == 0) n = n/2; else { n = n-1; x = 10*x + 3; y = y*10; } y = (y-1) / 3; here's the trace: notice the "heavy line" drawn each time the loop condition is tested, including the final test that evaluates to $false$. # # # # # # # # # # # # # # # # +--+-+-#----+---+---#---#---+----+-----#---#---#---#---+-----+------#-----+ n |19| | # 18 | | # 9 # 8 | | # 4 # 2 # 1 # 0 | | # | +--+-+-#----+---+---#---#---+----+-----#---#---#---#---+-----+------#-----+ x | |0| # | 3 | # # | 33 | # # # # | 333 | # | +--+-+-#----+---+---#---#---+----+-----#---#---#---#---+-----+------#-----+ y | | |1# | | 10# # | | 100 # # # # | | 1000 # 333 | +--+-+-#----+---+---#---#---+----+-----#---#---#---#---+-----+------#-----+ # # # # # # # # # # # # # # # #