Skip to content

Instantly share code, notes, and snippets.

@jkaihsu
Created March 7, 2013 08:19
Show Gist options
  • Save jkaihsu/5106408 to your computer and use it in GitHub Desktop.
Save jkaihsu/5106408 to your computer and use it in GitHub Desktop.
Write a method print_triangle which takes at its input an integer representing the number of rows to print, and prints out a right triangle consisting of * characters, one line per row. For example, print_triangle(5) should print out:
def print_triangle(rows)
for j in 1..rows do
for i in 1..j do
print "*" * 1
end
puts
end
end
@jsabato
Copy link

jsabato commented Jun 16, 2014

i just dont get how this works, yet it does

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment