Avoid NZEC Erlang Errors in SPOJ

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). 
+4
source share
1 answer

I got an answer. The trick is that the name of your module should always be tested , and the entry point should be the main one . For example, after compilation, it should run as verified: main () .

+4
source

Source: https://habr.com/ru/post/1316556/


All Articles