From: Robert Klemme Date: 2011-12-05T19:38:19+09:00 Subject: Re: Stupid question On Mon, Dec 5, 2011 at 10:03 AM, James Gallagher wrote: > Thank you everyone for Helping me out.  :-) If I am not mistaken, everybody in this thread resorted to using a string conversion. Why does nobody want to calculate this numerically? >> x = 2011 => 2011 >> q = 0 => 0 >> a = x => 2011 >> while a>0;a,b=a.divmod 10;q+=b;end => nil >> q => 4 Granted, this is not too short - but it works without creating a String instance. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/