[Jprogramming] Project Euler 20
Roger Hui
rogerhui.canada at gmail.com
Wed May 28 15:30:33 UTC 2014
+/ "."0 ": !100x
648
On Wed, May 28, 2014 at 8:26 AM, Jon Hough <jghough at outlook.com> wrote:
> 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
>
More information about the Programming
mailing list