Skip to content

Instantly share code, notes, and snippets.

@l0gicpath
Created January 31, 2014 13:35
Show Gist options
  • Save l0gicpath/8732180 to your computer and use it in GitHub Desktop.
Save l0gicpath/8732180 to your computer and use it in GitHub Desktop.
Because my other 5 line Erlang solution was too long.
-module(problem_2).
-export([s/0]).
-define(L, 4000000).
s() -> s(1, 2, 0).
s(P, N, S) when P >= ?L; N >= ?L -> S;
s(P, N, S) -> S1 = case N rem 2 of 0 -> N + S; _ -> S end, s(N, P + N, S1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment