by mhx@[EMAIL PROTECTED]
(Marcel Hendrix)
Apr 27, 2008 at 10:34 PM
William James <w_a_x_man@[EMAIL PROTECTED]
> writes Re: Euler problem #20
[..]
> Ruby:
> n = 1
> (2..100).each{|i| n *= i }
> s = n.to_s
> puts s.reverse.gsub( /.../, '\&,' ).reverse
> sum = 0
> s.split('').each{|c| sum += c.to_i }
> puts sum
Thanks, I hadn't realized that printing the number and parsing
the text output was an obvious solution :-(
That is probably how they do the 2^1000 problem. Just use dc to
print it to stdout.
-marcel