In this case, ": (format) converts the extended precision number to a
character vector and ". applies "activate" (which converts a character
representation of a number to numeric) to the rank 0 ("0 - scalar elements)
of the character vector, converting each digit to a number.On Wed, May 28, 2014 at 11:41 AM, Jon Hough <[email protected]> wrote: > I just tried using "."0 ": and it does exactly what I want. > Thanks.I just need to study ". and ": > > Date: Wed, 28 May 2014 08:30:33 -0700 > > From: [email protected] > > To: [email protected] > > Subject: Re: [Jprogramming] Project Euler 20 > > > > +/ "."0 ": !100x > > 648 > > > > > > > > On Wed, May 28, 2014 at 8:26 AM, Jon Hough <[email protected]> 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 > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
