       Re: count zeros in a number

• To: mathgroup at smc.vnet.net
• Subject: [mg121799] Re: count zeros in a number
• From: Ulrich Arndt <ulrich.arndt at data2knowledge.de>
• Date: Mon, 3 Oct 2011 04:21:00 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <201110020636.CAA28027@smc.vnet.net>

```one way is to convert the number to a string and count the "0" at the end

a = 24^24*55^55
StringLength[
StringCases[ToString[a],
Longest[x : "0" ... ~~ EndOfString] -> x]][]
a = 123
StringLength[
StringCases[ToString[a],
Longest[x : "0" ... ~~ EndOfString] -> x]][]
a = 1230
StringLength[
StringCases[ToString[a],
Longest[x : "0" ... ~~ EndOfString] -> x]][]

Ulrich

Am 02.10.2011 um 08:36 schrieb dimitris:

> 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.
>
> Thanks in advance.
> Dimitris
>

```

• 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