On Mon, Dec 5, 2011 at 10:03 AM, James Gallagher
<lollyproductions / mac.com> wrote:
> Thank you everyone for Helping me out. =A0:-)

If I am not mistaken, everybody in this thread resorted to using a
string conversion.  Why does nobody want to calculate this
numerically?

>> x =3D 2011
=3D> 2011
>> q =3D 0
=3D> 0
>> a =3D x
=3D> 2011
>> while a>0;a,b=3Da.divmod 10;q+=3Db;end
=3D> nil
>> q
=3D> 4

Granted, this is not too short - but it works without creating a
String instance.

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/