Project Euler

Problem #10

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.

Find the sum of all the primes below two million.

Erlang: Running time = 10.45s
+%echo

+%prime_list

+%prime_iterator

p10()->
	Iter=prime_iterator(self()),
	p10(0,Iter).
p10(Sum,Iter)->
	Iter ! next,
	Next=receive {prime,X}->X end,
	if 
		Next < 2000000 ->p10(Sum+Next,Iter);
		true->io:format("~w~n",[Sum])
	end.

Ruby: Running time = 28.48s
+#PrimeList

def p10
  p=PrimeList.new
  sum=0
  sum+=p.last while p.getNext<2000000
  puts sum
end

Scala: Running time = 0.86s
+//PrimeList

def p10{
  var tot=0L
  var i=0
  var p=0
  while(p<2000000){
    tot+=p
    p=PrimeList.get(i)
    i+=1
  }
  println(tot)
}