Apr 09
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).
My solution in Ruby:
sum = 0 for i in 1..1000 do sum += i**i end str = sum.to_s puts str[str.length - 10,str.length]
UPDATE
s = 0 (1..1000).inject { |s, x| s + x ** x } % (10 ** 10) str = s.to_s puts str[str.length - 10,str.length]