aboutsummaryrefslogtreecommitdiff
path: root/problem92.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 /problem92.erl
parent00686037d57eb0a0d5eba6eeb6fcc9692e8b59f6 (diff)
first commit
Diffstat (limited to 'problem92.erl')
-rwxr-xr-xproblem92.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/problem92.erl b/problem92.erl
new file mode 100755
index 0000000..3e4c5fe
--- /dev/null
+++ b/problem92.erl
@@ -0,0 +1,19 @@
+-module(problem92).
+-export([solve/0]).
+-import(lists,[filter/2,seq/2]).
+
+solve() ->
+ L = [ work(X) || X <- seq(1,9999999) ],
+ length(filter(fun(X) -> X end, L)).
+
+work(1) ->
+ false;
+work(89) ->
+ true;
+work(N) ->
+ work(add_squares([ X - 48 || X <- integer_to_list(N) ])).
+
+add_squares([]) ->
+ 0;
+add_squares([H|T]) ->
+ (H * H) + add_squares(T).