Here’s a function that will take an arbitrary number of ints as arguments.
To run the program, compile the code into a .beam file and use erl to execute it.
In Erlang, we achieve similar functionality using lists and pattern matching. The sum/1 function collects all arguments in a list and calculates the total sum using lists:sum/1. The main/0 function demonstrates calling the sum/1 function with few example cases.