Project Euler

Problem #52

It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.

Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.

Erlang: Running time = 2.79s
+%digit_split

p52()->
	put(six,lists:seq(1,6)),
	p52(1).
p52(N)->
	[First|Digs]=lists:map(fun(M)->lists:sort(digit_split(N*M)) end,get(six)),
	case lists:all(fun(X)->X==First end,Digs) of
		true-> io:format("~w~n",[N]);
		false->p52(N+1)
	end.

Ruby: Running time = 4.32s
+#dig_split

def p52
  x=0
  while true
    x+=1
    comp=dig_split(x).sort
    if (2..6).all?{|i|dig_split(x*i).sort==comp}
      puts x
      return
    end
  end
end