       Re: count zeros in a number

• To: mathgroup at smc.vnet.net
• Subject: [mg121826] Re: count zeros in a number
• From: Stefan Salanski <wutchamacallit27 at gmail.com>
• Date: Tue, 4 Oct 2011 01:31:26 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <j69104\$rda\$1@smc.vnet.net>

```On Oct 2, 2:40 am, dimitris <dimmec... 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:= Mod[24^24*55^55, 10^55]
> Mod[24^24*55^55, 10^56]
>
> Out= 0
> Out= 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.
>
> Dimitris

All these solutions are very interesting, and they all work, but I
believe the simplest solution is actually a built in function,
specifically: IntegerExponent[].
IntegerExponent[n,b] returns the highest power of b which divides n,
which for b=10, is the number of trailing zeroes of n.
moreover, the default value of b is already 10, so that
IntegerExponent[n] gives the number of trailing zeroes of n.
In:= IntegerExponent[24^24*55^55]
Out= 55
http://reference.wolfram.com/mathematica/ref/IntegerExponent.html

-Stefan Salanski

```

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