Project Euler

Problem #5

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?

Erlang: Running time = 0.12s
+%echo

+%prime_list

+%prime_iterator

+%factor

+%product

p5()->p5(2,[]).
p5(21,MyFactors)->io:format("~w~n",[product(MyFactors)]);
p5(N,MyFactors)->
	F=factor(N),
	p5(N+1,lists:append(lists:subtract(MyFactors,F),F)).

Ruby: Running time = 0.02s
+#PrimeList

+#factors

+#Enumerable

def p5
  fax=[]
  2.upto(20) do |i|
    f=factors i
    f.uniq.each{|j|fax.push j while fax.count(j)<f.count(j)}  
  end  
  puts fax.product
end