Processes recursivity

Im new with elixir and I want to create multiple process recursively.

The problems is that I dont know how to create another process because I create a process with a name but I cant create another process recursively because its the same name.

Why do you need to register your process under a name? You don’t seem to be using the name, so unless you have a need for it you can just skip the Process.register line.


Thank you, one last question each time I call spawn I create a process, and when I call :ok I close it after closing the last process the other process are closing recursively? because I dont know how to check all that process that I’ve created

:ok is not a call, it’s the return value in your function. If you want to wait for a process to compute a result, check Task.

Consider though that spawning processes helps when you can do things concurrently, while in your case the computation is completely sequential. If it’s an exercise to understand how processes work it’s ok, but there is no benefit in using processes in this case.