Project Euler

Problem #16

2^(15) = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.

What is the sum of the digits of the number 2^(1000)?

Clojure: Running time = 1.56s
+;digit-split

+;pow

(defn p16 []
  (println
    (apply + (digit-split (pow 2 1000)))
  )
)

Erlang: Running time = 0.12s
+%digit_split

+%pow

p16()->io:format("~w~n",[lists:sum(digit_split(pow(2,1000)))]).

Ruby: Running time = 0.02s
+#Enumerable

+#dig_split

def p16
  puts dig_split(2**1000).sum
end

Scala: Running time = 0.22s
+//pow

+//digitSplit

def p16{
  println(digitSplit(pow(2,1000)).foldLeft(0)(_+_))
}