1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/env escript %% -*- erlang -*- -module(factorial). -export([main/1]). -define(PREFIX, ?MODULE_STRING). main([In]) -> X = list_to_integer(In), N = fac(X), io:format("~s ~w = ~w~n",[?PREFIX, X, N]). fac(0) -> 1; fac(N) -> N * fac(N-1).