From 0248ed34ce3d05228bc5084669c3a27933be0c2e Mon Sep 17 00:00:00 2001 From: Nathan Lasseter Date: Sun, 4 Oct 2009 00:56:56 +0100 Subject: first commit --- problem39.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 problem39.erl (limited to 'problem39.erl') 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]. -- cgit v1.2.1