Project Euler

Problem #1

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

Clojure: Running time = 1.54s
+;nats

(defn p1 []
  (println
    (apply + (filter #(or (= 0 (rem % 3)) (= 0 (rem % 5))) (take 999 (nats))))
  )
)

Erlang: Running time = 0.198s
p1()->
	p1(1,0).
p1(1000,Sum)->io:format("~w~n",[Sum]);
p1(C,Sum)->
	if
		C rem 5 == 0; C rem 3 == 0->
			p1(C+1, Sum+C);
		true->
			p1(C+1, Sum)
	end.

Ruby: Running time = 0.01s
+#Enumerable

def p1
  puts (1...1000).select{|i|i%3==0 or i%5==0}.sum
end

Scala: Running time = 0.24s
def p1 {
  var x=0
  for(i <- (1 until 1000) if i%3==0 || i%5==0) x+=i
  println(x)
}