Project Euler Question 20 is:
n! means n  (n  1)  ...  3  2  1
For example, 10! = 10  9  ...  3  2  1 = 3628800,

and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
http://projecteuler.net/problem=20

My solution:
NB. create the base to split number


base =. 200 $ 10


NB. sum all


+/ @: (base & #: )@: ! 100x

I get the correct answer with this, but I am wondering if there is a terser or 
more elegant way to get the solution?
In particular I am not too happy about having to explicitly define the base. Is 
there a better way to convert numbers to arrays of their digits?


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

Reply via email to