Project Euler

Problem #20

n! means n × (n − 1) × ... × 3 × 2 × 1

Find the sum of the digits in the number 100!

Clojure: Running time = 1.62s
+;nats

+;factorial

+;digit-split

(defn p20 []
  (println
    (apply + (digit-split (factorial 100)))
  )
)

Erlang: Running time = 0.12s
+%digit_split

+%factorial

p20()->io:format("~w~n",[lists:sum(digit_split(factorial(100)))]).

Ruby: Running time = 0.01s
+#factorial

+#Enumerable

+#dig_split

def p20
  puts dig_split(factorial(100)).sum
end

Scala: Running time = 0.19s
+//digitSplit

+//factorial

def p20{
  println(digitSplit(factorial(100)).foldLeft(0)(_+_))
}