MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: count zeros in a number


n = 24^24*55^55

6998705566601499878519159087153235987310926417579055430641039765858300\
72320000000000000000000000000000000000000000000000000000000

IntegerDigits[n] /. {__, zeroes : 0 ..} :> Length@{zeroes}

55

The more complicated version:

IntegerDigits[n] /. {__, zeroes : Longest[0 ..]} :> Length@{zeroes}

55

isn't necessary, because __ is taken to mean Shortest[__] by default.

Bobby

On Sun, 02 Oct 2011 01:36:47 -0500, dimitris <dimmechan at 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
>


-- 
DrMajorBob at yahoo.com



  • Prev by Date: Re: count zeros in a number
  • Next by Date: Solve - takes very long time
  • Previous by thread: Re: count zeros in a number
  • Next by thread: Re: count zeros in a number