1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-module(problem5). -export([solve/0,test/2]). solve() -> test(1,20). test(Num,Max) -> T = wont_divide(Num,lists:seq(1,Max)), if T -> test(Num+1,Max); true -> Num end. wont_divide(_, []) -> false; wont_divide(Num, [H|T]) -> if Num rem H =/= 0 -> true; true -> wont_divide(Num, T) end.