Keep on moving

あんまりまとまってないことを書きますよ

Project Euler Prblem1

たまには勉強の腕試しにProject Eulerを解いてみた。
本日はレベル1

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.

要は1〜1000の数のうち、3or5の倍数をすべて足し合わせる問題。

%% Author: Ehren
-module(pje).

%%
%% Exported Functions
%%
-export([pje1/0]).

%%
%% API Functions
%%

pje1() ->
	lists:foldl(
	  fun(X,Y) -> X + Y end,
	  0,
	  lists:filter(fun(X) -> (X rem 5)*(X rem 3) == 0 end,lists:seq(1,1000))
			   ).

%% -> 234168

試しに、filterとfoldlを使って解いてみたけど、これは余り可読性が良くないですね。
あとあとリファクタリングが必要かな。