MathGroup Archive 2011

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

Search the Archive

Re: count zeros in a number

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121802] Re: count zeros in a number
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Mon, 3 Oct 2011 04:21:32 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201110020636.CAA28027@smc.vnet.net>

On 2 Oct 2011, at 08:36, dimitris 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
>

Probably the most obvious way is to let Mathematica multiply out the numbers and count the trailing zeros, eg.

Length[Last[Split[IntegerDigits[24^24*55^55]]]]

55


An alternative approach is to just count the exponents of 5 and 2 and take the smaller one:

Min[
 Cases[FactorInteger[24^24*55^55], {2, x_} | {5, y_} :> {x, y}]]

 55

Andrzej Kozlowski







  • Prev by Date: Re: count zeros in a number
  • Next by Date: Re: count zeros in a number
  • Previous by thread: Re: count zeros in a number
  • Next by thread: Re: count zeros in a number