Last active
January 15, 2016 23:00
-
-
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.
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
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