I wrote the code in Erlang and I got the correct answer on my machine. But when I send it to SPOJ , it gives an NZEC error (not a null exit code). I used built-in functions like halt() and init:stop() , and their specification clearly states that they are used to prevent non-zero exit code errors. But still I get the same error. How can I solve this problem?
EDIT Code as per comment:
-module(factorial). -export([main/0]). main() -> {ok, [No_of_cases]} = io:fread("", "~d"), loop(No_of_cases). loop(0) -> %init:stop(); halt(1); loop(No_of_cases) -> {ok, [Number]} = io:fread("", "~d"), ResultFactorial = find_factorial(Number,1), io:format("~p~n",[ResultFactorial]), loop(No_of_cases-1). find_factorial(0,Product) -> Product; find_factorial(Number,Product) -> find_factorial(Number-1,Product*Number).
source share