MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: discrete math, how many zeroes in 125!


Timothy Anderson wrote in message <6p6rjm$5lk at smc.vnet.net>...
>how can I solve this problem by counting the factors of 2 and 5 without
>doing each factor individually? thanks for any real quick help! Tim
>

I assume that you mean the zeroes at the end. Here are two ways  - I
change 125 to 1250 to ccompare speeds


Min[Cases[FactorInteger[1250!], {2|5, n_}->n]]//Timing

{1.48 Second, 312}

Position[Reverse[IntegerDigits[1250!]],Alternatives@@Range[9],
{1},1][[1,1]]-1//Timing

{0.28 Second, 312}

------------------------------------------------------------- 
Allan Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay at haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642



  • Prev by Date: Re: installing new packages in mathematica
  • Next by Date: Re: writing programs
  • Previous by thread: Re: Re: discrete math, how many zeroes in 125!
  • Next by thread: Re: discrete math, how many zeroes in 125!