Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Created January 26, 2012 12:16
Show Gist options
  • Save stepankuzmin/1682530 to your computer and use it in GitHub Desktop.
Save stepankuzmin/1682530 to your computer and use it in GitHub Desktop.
Project Euler. Problem 6.
-module(euler6).
-export([start/0]).
start() ->
N = fac(100),
N*N-fac2(100).
fac(N) ->
fac_acc(N, 0).
fac_acc(0, Acc) ->
Acc;
fac_acc(N, Acc) ->
fac_acc(N-1, Acc+N).
fac2(N) ->
fac2_acc(N, 0).
fac2_acc(0, Acc) ->
Acc;
fac2_acc(N, Acc) ->
fac2_acc(N-1, Acc+N*N).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment