Created
June 12, 2010 21:43
-
-
Save rodrigopinto/436113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(factorial). %% Definição do namespace, deve ter o mesmo nome do arquivo factorial.erl | |
-export([fac/1]). %% Exporta a função, ou seja, torna a função acessível fora do módulo. | |
fac(N) -> N * fac(N-1); %% Define uma cláusula para o fatorial quando parâmetro passado for diferente de 0 | |
fac(0) -> 1. %% Define uma cláusula para o fatorial quando parâmetro passado for 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment