Created
January 18, 2014 14:20
-
-
Save ph3nx/8491227 to your computer and use it in GitHub Desktop.
Ruby program that prints a multiplication table for numbers up to your input. For example 12 x 12 fields.
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 tbl max | |
for y in (1..max) do | |
for x in (1..max) do | |
sol = y*x | |
if sol < 10 | |
print "#{sol} " | |
elsif sol < 100 | |
print "#{sol} " | |
else | |
print "#{sol} " | |
end | |
end | |
print "\n" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tbl 23 is the maximum to fit in the windows PowerShell window.