Project Euler

Problem #48

The series, 1^(1) + 2^(2) + 3^(3) + ... + 10^(10) = 10405071317.

Find the last ten digits of the series, 1^(1) + 2^(2) + 3^(3) + ... + 1000^(1000).

Clojure: Running time = 2.08s
+;pow

+;pow-mod

(defn p48 []
  (println
    (let [mod (pow 10 10)]
      (rem (apply + (map #(pow-mod % % mod) (range 1 1001))) mod)
    )
  )
)

Erlang: Running time = 0.13s
+%pow

+%pow_mod

p48()->
	M=pow(10,10),
	io:format("~w~n",[lists:sum(lists:map(fun(X)->pow_mod(X,X,M) end, lists:seq(1,1000))) rem M]).

Ruby: Running time = 0.0s
+#power_mod

def p48
  p=10**10
  puts (1..1000).map{|i|power_mod(i,i,p)}.sum%p
end