Skip to content

Instantly share code, notes, and snippets.

@parksilk
Last active January 15, 2016 23:00
Show Gist options
  • Save parksilk/4522453 to your computer and use it in GitHub Desktop.
Save parksilk/4522453 to your computer and use it in GitHub Desktop.
Implement a method called times_table which takes as its input an integer and prints out a times table with that number of rows.
def times_table(rows)
1.upto(rows) do |r|
1.upto(rows) do |c|
print (r * c), "\t" # the "\t" tabbs over and creates better colums than spaces
end
print "\n"
end
end
# it's two loops and the variables that track the number of iteratinos (r and c)
# multiply together to make the times table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment