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: [mg121806] Re: count zeros in a number
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Mon, 3 Oct 2011 04:22:16 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 10/2/11 at 2:36 AM, dimmechan at yahoo.com (dimitris) wrote:

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

Here are a couple of ways:

In[10]:= Count[IntegerDigits[Mod[24^24*55^55, 10^56]], 0]

Out[10]= 55

In[11]:= Length[Split[IntegerDigits[Mod[24^24*55^55, 10^56]]][[-1]]]

Out[11]= 55

The first method assumes the only zeros are trailing zeros. The
second does not make this assumption by does assume there are
trailing zeros.




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