Hi, I am learning recursion these days and I wanted to implement a program that will print the values in Descending order (10, 9, 8, 7, 6, 5, …). As you can see in the following code. It should print out the positive values in descending order but it prints in ascending order.
Any Idea?
defmodule Recursion do
def count(0), do: :ok
def count(n) when n >= 0 do
count(n-1)
IO.puts(n)
end
def count(n) when n <=0 do
:negative
end
end