Keep on moving

あんまりまとまってないことを書きますよ

ex3.1

ex3.1

%% Author: Ehren
%% Created: 2009/11/29
%% Description: TODO: Add description to mymath
-module(mymath).

%%
%% Include files
%%

%%
%% Exported Functions
%%
-export([sum/2, sum/1]).

%%
%% API Functions
%%

%%
%% TODO: Add description of sum/function_arity
%%

sum(M,N) when M < N ->
   M + sum(M+1, N);
sum(M,N) when M > N ->
	{error,"First argument is less than Second argument"};
sum(N,N) ->
	N.



%%
%% TODO: Add description of sum/function_arity
%%
sum(N) when N > 0 ->
    N + sum(N - 1);
sum(0) -> 0.