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


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

Re: count zeros in a number

From Peter Breitfeld <phbrf@t-online.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: count zeros in a number
Date 2011-10-03 08:30 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j6brrn$8nu$1@smc.vnet.net> (permalink)
References <j69104$rda$1@smc.vnet.net>

Show all headers | View raw


dimitris wrote:

I would convert to a string and use a regular expression:

trailingZeros[n_] :=
 StringLength@StringCases[ToString[n], RegularExpression["0+$"]]

trailingZeros[24^24 55^55]
Out={55}

trailingZeros[10000!]
Out={2499}

> 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
>

-- 
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

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