Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

erlang

  • Loading branch information...
commit 9e7d5d2e14d8f796352ae94300e861cde9e36a40 1 parent 8768617
@kscaldef kscaldef authored
View
1  bin/compare_implementations.pl
@@ -13,6 +13,7 @@
# we should change perl6 to rakudo
perl6 => $ENV{PERL6} || catfile( $ENV{HOME},qw{git rakudo perl6}),
ruby => $ENV{RUBY} || 'ruby',
+ erlang => $ENV{ERLANG} || 'escript',
);
my ($profile_lang,$euler_problem,$count) = @ARGV;
View
1  bin/compare_problem_number.pl
@@ -13,6 +13,7 @@
# we should change perl6 to rakudo
perl6 => $ENV{RAKUDO} || $ENV{PERL6} || catfile( $ENV{HOME},qw{git rakudo perl6}),
ruby => $ENV{RUBY} || 'ruby',
+ erlang => $ENV{ERLANG} || 'escript',
);
my @languages = keys %interp;
View
17 erlang/001/01.erl
@@ -0,0 +1,17 @@
+#!/usr/bin/env escript
+
+main(_) ->
+ Sum = do_sum(0, 0),
+ io:format("~p~n", [Sum]).
+
+do_sum(1000, Acc) -> Acc;
+do_sum(N, Acc) ->
+ NewAcc =
+ case N of
+ M when M rem 3 == 0 -> Acc + N;
+ M when M rem 5 == 0 -> Acc + N;
+ _ -> Acc
+ end,
+ do_sum(N+1, NewAcc).
+
+
View
6 erlang/001/02.erl
@@ -0,0 +1,6 @@
+#!/usr/bin/env escript
+
+main(_) ->
+ Sum = lists:sum([ X || X <- lists:seq(1,999),
+ X rem 3 == 0 orelse X rem 5 == 0]),
+ io:format("~p~n", [Sum]).

0 comments on commit 9e7d5d2

Please sign in to comment.
Something went wrong with that request. Please try again.