9 lines
347 B
Erlang
9 lines
347 B
Erlang
|
-module(e2).
|
||
|
-export([e2/0, fib_count/4]).
|
||
|
|
||
|
fib_count(Last, Current, Max, Sum) when Current >= Max -> Sum;
|
||
|
fib_count(Last, Current, Max, Sum) when Current rem 2 == 0 -> fib_count(Current, Last + Current, Max, Sum + Current);
|
||
|
fib_count(Last, Current, Max, Sum) -> fib_count(Current, Last + Current, Max, Sum).
|
||
|
|
||
|
e2() -> fib_count(0, 1, 4000000, 0).
|