Actually, I don’t think recursion is hard, It’s quite easy if you’re familiar with C.
Example in C:
#include <stdio.h>
void recurse ( int count ) /* Each call gets its own copy of count */
{
printf( "%d\n", count );
if (count <= 0) return;
recurse ( count - 1 );
}
int main(int argc, char **argv)
{
recurse (10);
return 0;
}
This is basically the same thing in Elixir:
defmodule Recurse do
def print_number(n) when n <= 0 do
IO.puts n
end
def print_number(n) do
IO.puts n
print_number(n - 1)
end
end






















