Created
December 23, 2022 20:58
-
-
Save vKxni/5ad9709c7e261c6e7d43c03935e47bae to your computer and use it in GitHub Desktop.
A simple tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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