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