-module euler2 -export find_sum find_sum when if rem find_sum true fin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
-module(euler2).
-export([find_sum/1]).
find_sum(S, A, B, N) when A<N ->
if
A rem 2 == 0 ->
find_sum(S+A, B, A+B, N);
true -> find_sum(S, B, A+B, N)
end;
find_sum(S, A, _, N) when A>=N ->
S.
find_sum(N) ->
find_sum(0, 1, 2, N).