Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5355

Re: count zeros in a number

From Stefan Salanski <wutchamacallit27@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: count zeros in a number
Date 2011-10-04 05:34 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j6e5ti$kbr$1@smc.vnet.net> (permalink)
References <j69104$rda$1@smc.vnet.net>

Show all headers | View raw


On Oct 2, 2:40 am, dimitris <dimmec...@yahoo.com> wrote:
> Hello.
>
> Consider e.g. the number 24^24*55^55.
> This number ends with exactly 55 zeros as the following demonstrate
>
> In[201]:= Mod[24^24*55^55, 10^55]
> Mod[24^24*55^55, 10^56]
>
> Out[201]= 0
> Out[202]= 20000000000000000000000000000000000000000000000000000000
>
> What I want now is a way to count the zeros that a number ends without
> knowing in advance this number of zeros like in the above example.
>
> Thanks in advance.
> Dimitris

All these solutions are very interesting, and they all work, but I
believe the simplest solution is actually a built in function,
specifically: IntegerExponent[].
IntegerExponent[n,b] returns the highest power of b which divides n,
which for b=10, is the number of trailing zeroes of n.
moreover, the default value of b is already 10, so that
IntegerExponent[n] gives the number of trailing zeroes of n.
In[1]:= IntegerExponent[24^24*55^55]
Out[1]= 55
http://reference.wolfram.com/mathematica/ref/IntegerExponent.html

-Stefan Salanski

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

count zeros in a number dimitris <dimmechan@yahoo.com> - 2011-10-02 06:40 +0000
  Re: count zeros in a number DC <b.gatessucks@gmail.com> - 2011-10-03 08:20 +0000
  Re: count zeros in a number Mark Adler <madler@alumni.caltech.edu> - 2011-10-03 08:22 +0000
  Re: count zeros in a number Peter Pein <petsie@dordos.net> - 2011-10-03 08:29 +0000
  Re: count zeros in a number Peter Breitfeld <phbrf@t-online.de> - 2011-10-03 08:30 +0000
  Re: count zeros in a number "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-10-03 08:28 +0000
  Re: count zeros in a number Stefan Salanski <wutchamacallit27@gmail.com> - 2011-10-04 05:34 +0000
    Re: count zeros in a number Richard Fateman <fateman@cs.berkeley.edu> - 2011-10-05 08:14 +0000
      Re: count zeros in a number -> Clip[x] = ? "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-10-06 08:35 +0000
      Re: count zeros in a number Mark Adler <madler@alumni.caltech.edu> - 2011-10-06 08:40 +0000
    Re: count zeros in a number DrMajorBob <btreat1@austin.rr.com> - 2011-10-06 08:32 +0000
  Re: count zeros in a number DrMajorBob <btreat1@austin.rr.com> - 2011-10-04 05:35 +0000
  Re: count zeros in a number dimitris <dimmechan@yahoo.com> - 2011-10-04 05:30 +0000

csiph-web