Skip to content

Instantly share code, notes, and snippets.

@maiah
Created November 3, 2015 09:01
Show Gist options
  • Save maiah/5fc20f2e46c2a36f9438 to your computer and use it in GitHub Desktop.
Save maiah/5fc20f2e46c2a36f9438 to your computer and use it in GitHub Desktop.
defmodule P2 do
def num_to_list(mx) when mx > 1 do
num_to_list(mx, mx - 1)
end
def num_to_list(mx) do
"#{mx}"
end
defp num_to_list(n, mx) when mx > 1 do
num_to_list("#{mx},#{n}", mx - 1)
end
defp num_to_list(n, mx) do
"#{mx},#{n}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment