aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/escript_SUITE_data/factorial_epp
blob: dbdf97498506b9a8a5137d678e950f83b144d44e (plain) (blame)
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).