aboutsummaryrefslogtreecommitdiff
path: root/problem92.erl
blob: 3e4c5fe0e643f78d4af0b8d39c12c15ba8164d7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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).