2011-03-27 17:31:47 +00:00
|
|
|
-module(e1).
|
2011-03-31 20:53:27 +00:00
|
|
|
-export([e1/0]).
|
2011-03-27 17:31:47 +00:00
|
|
|
|
2011-03-31 20:53:27 +00:00
|
|
|
add_list([], Acc) -> Acc;
|
|
|
|
add_list([X| Tail], Acc) -> add_list(Tail, Acc+X).
|
|
|
|
|
|
|
|
find_3_5_divisibles(Start, Max) -> find_3_5_divisibles(Start, Max, []).
|
|
|
|
|
|
|
|
find_3_5_divisibles(Max, Max, Acc) -> Acc;
|
|
|
|
find_3_5_divisibles(Start, Max, Acc) when Start rem 3 == 0; Start rem 5 == 0 -> find_3_5_divisibles(Start+1, Max, [Start |Acc]);
|
|
|
|
find_3_5_divisibles(Start, Max, Acc) -> find_3_5_divisibles(Start+1, Max, Acc).
|
|
|
|
|
|
|
|
e1() -> add_list(find_3_5_divisibles(2, 1000), 0).
|