Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5329 > unrolled thread
| Started by | Andrzej Kozlowski <akoz@mimuw.edu.pl> |
|---|---|
| First post | 2011-10-03 08:25 +0000 |
| Last post | 2011-10-03 08:25 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: count zeros in a number Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-10-03 08:25 +0000
| From | Andrzej Kozlowski <akoz@mimuw.edu.pl> |
|---|---|
| Date | 2011-10-03 08:25 +0000 |
| Subject | Re: count zeros in a number |
| Message-ID | <j6brgt$8lo$1@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
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web