aboutsummaryrefslogtreecommitdiff
path: root/problem39.erl
diff options
context:
space:
mode:
Diffstat (limited to 'problem39.erl')
-rwxr-xr-xproblem39.erl11
1 files changed, 11 insertions, 0 deletions
diff --git a/problem39.erl b/problem39.erl
new file mode 100755
index 0000000..1981d16
--- /dev/null
+++ b/problem39.erl
@@ -0,0 +1,11 @@
+-module(problem39).
+-export([solve/0]).
+
+solve() ->
+ N = lists:seq(1,1000),
+ L = [{X,length(pythag(X))} || X <- N],
+ hd(lists:sort(fun({_,A},{_,B}) -> A > B end, L)).
+
+pythag(N) ->
+ D = lists:seq(1,N),
+ [{A,B,C} || A <- D,B <- D, C <- D, A+B+C=:=N, A*A+B*B=:=C*C].