-module(euler1).
-export([solve/0, solve/1]).
solve() ->
solve(999).
solve(N) when is_integer(N) ->
if
N == 0 ->
0;
N rem 3 == 0 ->
N + solve(N-1);
N rem 5 == 0 ->
N + solve(N-1);
true ->
solve(N-1)
end.
Thursday, January 8, 2009
Erlang solution to Euler problem 1
I've decided to get serious about learning Erlang by solving one project Euler problem a day. Here's what I came up with for problem 1.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment