Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5338 > unrolled thread

Re: count zeros in a number

Started byUlrich Arndt <ulrich.arndt@data2knowledge.de>
First post2011-10-03 08:23 +0000
Last post2011-10-03 08:23 +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.


Contents

  Re: count zeros in a number Ulrich Arndt <ulrich.arndt@data2knowledge.de> - 2011-10-03 08:23 +0000

#5338 — Re: count zeros in a number

FromUlrich Arndt <ulrich.arndt@data2knowledge.de>
Date2011-10-03 08:23 +0000
SubjectRe: count zeros in a number
Message-ID<j6brdu$8k9$1@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]][[1]]
a = 123
StringLength[
  StringCases[ToString[a], 
   Longest[x : "0" ... ~~ EndOfString] -> x]][[1]]
a = 1230
StringLength[
  StringCases[ToString[a], 
   Longest[x : "0" ... ~~ EndOfString] -> x]][[1]]

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


[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web