x = 24987654 x -= x % (10 ** (Math.log(x, 10).to_i - 1)) puts x
Standard input is empty
24000000
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!