Re: count zeros in a number

*To*: mathgroup at smc.vnet.net*Subject*: [mg121854] Re: count zeros in a number*From*: DrMajorBob <btreat1 at austin.rr.com>*Date*: Wed, 5 Oct 2011 04:00:12 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <201110020636.CAA28027@smc.vnet.net> <j6brvm$8om$1@smc.vnet.net>*Reply-to*: drmajorbob at yahoo.com

There's nothing "esoteric" about IntegerDigits, Replace, or Repeated, as in: x = 24^24*55^55; Replace[IntegerDigits@x, {__, zeroes : 0 ..} :> Length@{zeroes}] // Timing {0.000185, 55} If we wanted brute-force arithmetic, we might use Fortran. Your suggested solutions are NOT greatly hindered by "the slow implementation of looping constructs in Mathematica", on the other hand: (n = 0; While[GCD[x, 10^n] == 10^n, n++]; n - 1) // Timing {0.000029, 0} (n = 0; While[Mod[x, 10] == 0, (x = x/10; n++)]; n) // Timing {0.000018, 0} Bobby On Tue, 04 Oct 2011 00:30:21 -0500, Richard Fateman <fateman at cs.berkeley.edu> wrote: > How disappointing that the usual crew did not come up with a way of > solving this simply, arithmetically, like this: > > (n = 0; While[GCD[24^24*55^55, 10^n] == 10^n, n++]; n - 1) > > or > > (n = 0; x = 24^24*55^55; > While[Mod[x, 10] == 0, (x = x/10; n++) ]; n) > > or any of the numerous minor variants.... > > but instead resorted to conversion to strings or factoring. > > The arithmentic methods may be slower since they rely on the slow > implementation of looping constructs in Mathematica, but they > don't require any of the more esoteric features like > Exponents, Split, IntegerDigits, ... > > RJF > -- DrMajorBob at yahoo.com

**References**:**count zeros in a number***From:*dimitris <dimmechan@yahoo.com>