Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5343
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: count zeros in a number |
| Date | 2011-10-03 08:29 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j6brpp$8nd$1@smc.vnet.net> (permalink) |
| References | <j69104$rda$1@smc.vnet.net> |
Am 02.10.2011 08:40, schrieb dimitris:
> 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
>
Using pattern matching makes this an easy one :-)
In[1]:= TrailingZeros[n_Integer] :=
IntegerDigits[n] /. {___, Except[0], z: ((0) ...)} :> Length[{z}]
TrailingZeros[24^24 55^55]
Out[2]= 55
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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