Adding euler: cs and erlang, and a Makefile for cleaning and basic building
This commit is contained in:
parent
f2cd84cffc
commit
3d62d1bdf7
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
public class E1
|
||||
{
|
||||
public static void Main() {
|
||||
int sum = 0;
|
||||
for(int i = 2; i < 1000; i++) {
|
||||
if (i % 3 == 0 || i % 5 == 0)
|
||||
sum += i;
|
||||
}
|
||||
System.Console.WriteLine(sum);
|
||||
}
|
||||
}
|
13
e1.erl
13
e1.erl
|
@ -1,4 +1,13 @@
|
|||
-module(e1).
|
||||
-export([e1/1]).
|
||||
-export([e1/0]).
|
||||
|
||||
e1(
|
||||
add_list([], Acc) -> Acc;
|
||||
add_list([X| Tail], Acc) -> add_list(Tail, Acc+X).
|
||||
|
||||
find_3_5_divisibles(Start, Max) -> find_3_5_divisibles(Start, Max, []).
|
||||
|
||||
find_3_5_divisibles(Max, Max, Acc) -> Acc;
|
||||
find_3_5_divisibles(Start, Max, Acc) when Start rem 3 == 0; Start rem 5 == 0 -> find_3_5_divisibles(Start+1, Max, [Start |Acc]);
|
||||
find_3_5_divisibles(Start, Max, Acc) -> find_3_5_divisibles(Start+1, Max, Acc).
|
||||
|
||||
e1() -> add_list(find_3_5_divisibles(2, 1000), 0).
|
||||
|
|
Loading…
Reference in New Issue