I don't know where you're going with this, but, just based on the minimal
statement of the problem, I probably would have done it something like this
(for your example):

   2+/ . =q:!10
8

However, I'm guessing you can't use "q:" because it's a "large factorial".
 That being the
case, I don't know how to use the function you provided as you give no
example.  That is, I tried the
obvious:

   !10
3628800
   f=: 2&{@:((0&{ , (0 , 2&{) + [: <. 1&{ % 0&{)^:_)
   f 2 3628800 0
3628789

which isn't right.

On 4/12/08, Geoff Canyon <[EMAIL PROTECTED]> wrote:
>
> I've created a function to figure out how many times a large factorial
> will have a given number as a factor.
>
> So for example, !10 has 2 as a factor 8 times:
>
> 2  1
> 4  2
> 6  1
> 8  3
> 10 1
>
> Here's the function I defined to calculate this:
>
> f=: 2&{@:((0&{ , (0 , 2&{) + [: <. 1&{ % 0&{)^:_)
>
> It takes three arguments: the factor, the factorial, and the starting
> number for the factor-count, which should always be 0.
>
> It divides the factorial number by the factor repeatedly, keeping track of
> the sum of the quotients, and at the end outputs just the sum.
>
> Is this a reasonable job of J programming? Is there a better way to have
> coded this?
>
> regards,
>
> Geoff
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to