Don't forget #.~ to calculate the number of trailing 1s.  As in

  m10d=: [: #.~ '0' = ":@[EMAIL PROTECTED]:

It's not as slow as you might think and compares to <m10i>.


--- Arie Groeneveld <[EMAIL PROTECTED]> wrote:

> j4F&FWIW
> 
> 
> Calculating trailing zero's of factorial (n)
> First an intuitive version:
> 
> m10i=: 13 : '{. I. 0= ''0''=  |. ": ! x: y'
> 
> And a fast one if needed:
> 
> m10=: [: +/ [: }. ([: <. 5%~])^:(0&<)^:a:
> 
> 
>    (m10i 5000) -: m10 5000
> 1
>    ts 'm10i 5000x'  
> 0.299809 453376
> 
>    ts 'm10 5000x'  
> 6.4e_5 2944
> 
>    m10i 5000
> 1249
> 
>    m10 5000
> 1249
> 
> 
> 
> 
> @@i
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 



      
____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel 
and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to