-module euler1 -export find_sum find_sum when if rem or rem find_sum t

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