aboutsummaryrefslogtreecommitdiff
path: root/problem5.erl
diff options
context:
space:
mode:
authorNathan Lasseter <nathan.je.lasseter@googlemail.com>2009-10-04 00:56:56 +0100
committerNathan Lasseter <nathan.je.lasseter@googlemail.com>2009-10-04 00:56:56 +0100
commit0248ed34ce3d05228bc5084669c3a27933be0c2e (patch)
treeb9c4990344b0863a2af851b5917c49f3a5f03e6b /problem5.erl
parent00686037d57eb0a0d5eba6eeb6fcc9692e8b59f6 (diff)
first commit
Diffstat (limited to 'problem5.erl')
-rwxr-xr-xproblem5.erl23
1 files changed, 23 insertions, 0 deletions
diff --git a/problem5.erl b/problem5.erl
new file mode 100755
index 0000000..8f1fbbc
--- /dev/null
+++ b/problem5.erl
@@ -0,0 +1,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.