Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 364 Bytes

erlang入门.md

File metadata and controls

18 lines (13 loc) · 364 Bytes

Introduction to Erlang

-module(fact).
-export([factorial/1]).

factorial(N) -> factorial(1,N,1).

factorial(Current, N, Result) when Current =< N
   NewResult = Result*Current,
   io:format("~w yield ~w!~n", [Current, NewResult]),
   factorial(Current+1, N, NewResult);

 factorial(Current, N, Result) ->
    io: format("Finished.~n"),
    Result.