aboutsummaryrefslogtreecommitdiff
path: root/problem5.erl
blob: 8f1fbbcb6dc3bb332db4c1335a4438f1d3131aab (plain)
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.