Skip to content

Instantly share code, notes, and snippets.

@vKxni
Created December 23, 2022 20:58
Show Gist options
  • Save vKxni/5ad9709c7e261c6e7d43c03935e47bae to your computer and use it in GitHub Desktop.
Save vKxni/5ad9709c7e261c6e7d43c03935e47bae to your computer and use it in GitHub Desktop.
A simple tree
defmodule Pyramid do
def print(n) do
for row <- 1..n do
print_row(row)
end
end
defp print_row(row) do
# Concatenate the asterisks instead of multiplying them
IO.puts(String.duplicate("*", row))
end
end
Pyramid.print(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment